結果
問題 | No.1093 区間の和 / Sum of Range |
ユーザー |
|
提出日時 | 2020-06-24 01:52:16 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 206 ms / 2,000 ms |
コード長 | 5,019 bytes |
コンパイル時間 | 2,237 ms |
コンパイル使用メモリ | 105,712 KB |
実行使用メモリ | 34,564 KB |
最終ジャッジ日時 | 2023-09-16 20:28:56 |
合計ジャッジ時間 | 8,935 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 59 ms
22,856 KB |
testcase_01 | AC | 133 ms
30,000 KB |
testcase_02 | AC | 89 ms
25,460 KB |
testcase_03 | AC | 108 ms
27,356 KB |
testcase_04 | AC | 103 ms
29,152 KB |
testcase_05 | AC | 155 ms
29,724 KB |
testcase_06 | AC | 88 ms
24,284 KB |
testcase_07 | AC | 118 ms
27,792 KB |
testcase_08 | AC | 135 ms
34,564 KB |
testcase_09 | AC | 140 ms
26,232 KB |
testcase_10 | AC | 131 ms
32,644 KB |
testcase_11 | AC | 144 ms
27,940 KB |
testcase_12 | AC | 132 ms
29,760 KB |
testcase_13 | AC | 65 ms
21,004 KB |
testcase_14 | AC | 145 ms
29,040 KB |
testcase_15 | AC | 94 ms
24,444 KB |
testcase_16 | AC | 174 ms
31,740 KB |
testcase_17 | AC | 138 ms
28,096 KB |
testcase_18 | AC | 124 ms
27,144 KB |
testcase_19 | AC | 72 ms
23,540 KB |
testcase_20 | AC | 109 ms
27,632 KB |
testcase_21 | AC | 165 ms
29,512 KB |
testcase_22 | AC | 179 ms
31,800 KB |
testcase_23 | AC | 129 ms
27,864 KB |
testcase_24 | AC | 98 ms
26,688 KB |
testcase_25 | AC | 142 ms
27,660 KB |
testcase_26 | AC | 142 ms
32,388 KB |
testcase_27 | AC | 156 ms
29,196 KB |
testcase_28 | AC | 144 ms
32,636 KB |
testcase_29 | AC | 206 ms
31,488 KB |
testcase_30 | AC | 81 ms
21,884 KB |
testcase_31 | AC | 93 ms
22,948 KB |
testcase_32 | AC | 100 ms
26,828 KB |
testcase_33 | AC | 173 ms
30,564 KB |
testcase_34 | AC | 74 ms
21,192 KB |
testcase_35 | AC | 150 ms
25,352 KB |
testcase_36 | AC | 167 ms
33,928 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.IO; using System.Collections.Generic; using System.Linq; namespace AtCoder.Contest.F { static class Program { public static void Solve(Scanner cin) { int n = cin.ReadInt(); int k = cin.ReadInt(); var a = cin.ReadIntArray(n); int q = cin.ReadInt(); int now = 0; for (int i = 0; i < k; i++) { now += a[i]; } var l = new List<int>(); l.Add(now); for (int i = 0; i < n - k; i++) { now += a[i + k]; now -= a[i]; l.Add(now); } l.Sort(); for (int i = 0; i < q; i++) { Console.WriteLine(l.UpperBound(cin.ReadInt())); } } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } } static class BinarySearch { public static int UpperBound<T>(T[] array, T value) => UpperBound(array, 0, array.Length - 1, value, Comparer<T>.Default); public static int UpperBound<T>(T[] array, T value, Comparer<T> comparer) => UpperBound(array, 0, array.Length - 1, value, comparer); public static int UpperBound<T>(T[] array, int index, int length, T value) => UpperBound(array, index, length, value, Comparer<T>.Default); public static int UpperBound<T>(T[] array, int index, int length, T value, Comparer<T> comparer) { var l = index; var r = l + length - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = comparer.Compare(array[mid], value); if (res <= 0) l = mid + 1; else r = mid - 1; } return l; } public static int UpperBound<T>(this List<T> list, T item) => list.UpperBound(0, list.Count, item, Comparer<T>.Default); public static int UpperBound<T>(this List<T> list, T item, Comparer<T> comparer) => list.UpperBound(0, list.Count, item, comparer); public static int UpperBound<T>(this List<T> list, int index, int count, T item, Comparer<T> comparer) { var l = index; var r = l + count - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = comparer.Compare(list[mid], item); if (res <= 0) l = mid + 1; else r = mid - 1; } return l; } public static int LowerBound<T>(T[] array, T value) => LowerBound(array, 0, array.Length - 1, value, Comparer<T>.Default); public static int LowerBound<T>(T[] array, T value, Comparer<T> comparer) => LowerBound(array, 0, array.Length - 1, value, comparer); public static int LowerBound<T>(T[] array, int index, int length, T value) => LowerBound(array, index, length, value, Comparer<T>.Default); public static int LowerBound<T>(T[] array, int index, int length, T value, Comparer<T> comparer) { var l = index; var r = l + length - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = comparer.Compare(array[mid], value); if (res == -1) l = mid + 1; else r = mid - 1; } return l; } public static int LowerBound<T>(this List<T> list, T item) => list.LowerBound(0, list.Count, item, Comparer<T>.Default); public static int LowerBound<T>(this List<T> list, T item, Comparer<T> comparer) => list.LowerBound(0, list.Count, item, comparer); public static int LowerBound<T>(this List<T> list, int index, int count, T item, Comparer<T> comparer) { var l = index; var r = l + count - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = comparer.Compare(list[mid], item); if (res == -1) l = mid + 1; else r = mid - 1; } return l; } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); } }