結果

問題 No.1093 区間の和 / Sum of Range
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-26 00:21:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 2,717 ms
コンパイル使用メモリ 149,948 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 23:22:16
合計ジャッジ時間 7,570 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 98 ms
4,376 KB
testcase_02 AC 45 ms
4,376 KB
testcase_03 AC 27 ms
4,380 KB
testcase_04 AC 26 ms
4,376 KB
testcase_05 AC 150 ms
4,380 KB
testcase_06 AC 30 ms
4,380 KB
testcase_07 AC 79 ms
4,380 KB
testcase_08 AC 67 ms
4,380 KB
testcase_09 AC 125 ms
4,376 KB
testcase_10 AC 70 ms
4,376 KB
testcase_11 AC 117 ms
4,380 KB
testcase_12 AC 69 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 132 ms
4,380 KB
testcase_15 AC 33 ms
4,376 KB
testcase_16 AC 154 ms
4,376 KB
testcase_17 AC 127 ms
4,376 KB
testcase_18 AC 85 ms
4,376 KB
testcase_19 AC 10 ms
4,376 KB
testcase_20 AC 69 ms
4,376 KB
testcase_21 AC 156 ms
4,380 KB
testcase_22 AC 151 ms
4,380 KB
testcase_23 AC 112 ms
4,380 KB
testcase_24 AC 33 ms
4,380 KB
testcase_25 AC 139 ms
4,376 KB
testcase_26 AC 100 ms
4,376 KB
testcase_27 AC 130 ms
4,380 KB
testcase_28 AC 88 ms
4,376 KB
testcase_29 AC 192 ms
4,376 KB
testcase_30 AC 23 ms
4,376 KB
testcase_31 AC 32 ms
4,376 KB
testcase_32 AC 50 ms
4,380 KB
testcase_33 AC 149 ms
4,380 KB
testcase_34 AC 10 ms
4,376 KB
testcase_35 AC 159 ms
4,376 KB
testcase_36 AC 124 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.26 00:21:15
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,k;cin >> n >> k;
    vector<int> a(n);
    vector<int> s;
    int total = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        total += a[i];
        if (i >= k-1) {
            s.push_back(total);
            total -= a[i-k+1];
        }
    }
    sort(s.begin(), s.end());
    int q;cin >> q;
    for (int i = 0; i < q; i++) {
        int x;cin >> x;
        cout << upper_bound(s.begin(), s.end(), x) - s.begin() << endl;
    }
    return 0;
}
0