結果

問題 No.1093 区間の和 / Sum of Range
ユーザー forest3forest3
提出日時 2020-06-29 12:39:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 171,428 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 12:53:03
合計ジャッジ時間 9,399 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 107 ms
4,376 KB
testcase_02 AC 51 ms
4,376 KB
testcase_03 AC 31 ms
4,376 KB
testcase_04 AC 28 ms
4,376 KB
testcase_05 AC 160 ms
4,376 KB
testcase_06 AC 34 ms
4,376 KB
testcase_07 AC 89 ms
4,380 KB
testcase_08 AC 76 ms
4,380 KB
testcase_09 AC 139 ms
4,376 KB
testcase_10 AC 78 ms
4,380 KB
testcase_11 AC 132 ms
4,376 KB
testcase_12 AC 77 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 138 ms
4,376 KB
testcase_15 AC 36 ms
4,380 KB
testcase_16 AC 166 ms
4,380 KB
testcase_17 AC 133 ms
4,376 KB
testcase_18 AC 90 ms
4,376 KB
testcase_19 AC 10 ms
4,376 KB
testcase_20 AC 73 ms
4,380 KB
testcase_21 AC 165 ms
4,376 KB
testcase_22 AC 163 ms
4,380 KB
testcase_23 AC 124 ms
4,380 KB
testcase_24 AC 35 ms
4,504 KB
testcase_25 AC 147 ms
4,380 KB
testcase_26 AC 105 ms
4,376 KB
testcase_27 AC 152 ms
4,380 KB
testcase_28 AC 99 ms
4,380 KB
testcase_29 AC 207 ms
4,496 KB
testcase_30 AC 25 ms
4,376 KB
testcase_31 AC 34 ms
4,380 KB
testcase_32 AC 52 ms
4,376 KB
testcase_33 AC 157 ms
4,376 KB
testcase_34 AC 12 ms
4,376 KB
testcase_35 AC 164 ms
4,376 KB
testcase_36 AC 135 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> a( N );
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
	}

	vector<long long> S;
	long long s = 0;
	for( int i = 0; i < K; i++ ) {
		s += a[i];
	}
	S.push_back( s );
	for( int i = 0; i < N - K; i++ ) {
		s += a[i + K] - a[i];
		S.push_back( s );
	}
	sort( S.begin(), S.end() );
	int Q;
	cin >> Q;
	for( int i = 0; i < Q; i++ ) {
		long long x;
		cin >> x;
		int ans = upper_bound( S.begin(), S.end(), x ) - S.begin();
		cout << ans << endl;
	}
}
0