結果
問題 | No.1093 区間の和 / Sum of Range |
ユーザー | fairy_lettuce |
提出日時 | 2020-06-24 01:52:16 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 183 ms / 2,000 ms |
コード長 | 5,019 bytes |
コンパイル時間 | 880 ms |
コンパイル使用メモリ | 115,280 KB |
実行使用メモリ | 30,976 KB |
最終ジャッジ日時 | 2024-07-03 19:42:29 |
合計ジャッジ時間 | 7,312 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
17,920 KB |
testcase_01 | AC | 104 ms
25,600 KB |
testcase_02 | AC | 60 ms
22,272 KB |
testcase_03 | AC | 75 ms
25,472 KB |
testcase_04 | AC | 67 ms
25,088 KB |
testcase_05 | AC | 129 ms
25,088 KB |
testcase_06 | AC | 54 ms
22,528 KB |
testcase_07 | AC | 89 ms
25,088 KB |
testcase_08 | AC | 100 ms
30,080 KB |
testcase_09 | AC | 108 ms
23,552 KB |
testcase_10 | AC | 102 ms
28,288 KB |
testcase_11 | AC | 112 ms
25,344 KB |
testcase_12 | AC | 103 ms
27,264 KB |
testcase_13 | AC | 32 ms
18,560 KB |
testcase_14 | AC | 119 ms
24,576 KB |
testcase_15 | AC | 58 ms
22,656 KB |
testcase_16 | AC | 145 ms
26,880 KB |
testcase_17 | AC | 112 ms
23,680 KB |
testcase_18 | AC | 92 ms
24,576 KB |
testcase_19 | AC | 39 ms
20,096 KB |
testcase_20 | AC | 76 ms
23,040 KB |
testcase_21 | AC | 134 ms
25,088 KB |
testcase_22 | AC | 147 ms
27,392 KB |
testcase_23 | AC | 98 ms
23,040 KB |
testcase_24 | AC | 66 ms
25,088 KB |
testcase_25 | AC | 117 ms
25,216 KB |
testcase_26 | AC | 118 ms
27,776 KB |
testcase_27 | AC | 131 ms
24,704 KB |
testcase_28 | AC | 113 ms
28,160 KB |
testcase_29 | AC | 183 ms
30,976 KB |
testcase_30 | AC | 48 ms
21,504 KB |
testcase_31 | AC | 62 ms
22,808 KB |
testcase_32 | AC | 73 ms
24,100 KB |
testcase_33 | AC | 148 ms
28,032 KB |
testcase_34 | AC | 39 ms
19,456 KB |
testcase_35 | AC | 124 ms
22,912 KB |
testcase_36 | AC | 145 ms
29,312 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)); } }