結果

問題 No.1093 区間の和 / Sum of Range
ユーザー rogi52rogi52
提出日時 2022-10-04 01:41:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 596 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 205,436 KB
実行使用メモリ 5,704 KB
最終ジャッジ日時 2023-08-27 22:51:18
合計ジャッジ時間 9,027 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 82 ms
4,380 KB
testcase_02 AC 40 ms
4,380 KB
testcase_03 AC 18 ms
5,376 KB
testcase_04 AC 14 ms
5,108 KB
testcase_05 AC 125 ms
4,380 KB
testcase_06 AC 24 ms
4,376 KB
testcase_07 AC 65 ms
4,380 KB
testcase_08 AC 51 ms
5,168 KB
testcase_09 AC 107 ms
4,376 KB
testcase_10 AC 57 ms
4,780 KB
testcase_11 AC 107 ms
4,380 KB
testcase_12 AC 61 ms
4,668 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 120 ms
4,376 KB
testcase_15 AC 26 ms
4,376 KB
testcase_16 AC 140 ms
4,624 KB
testcase_17 AC 117 ms
4,380 KB
testcase_18 AC 78 ms
4,376 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 64 ms
4,376 KB
testcase_21 AC 140 ms
4,376 KB
testcase_22 AC 130 ms
4,600 KB
testcase_23 AC 101 ms
4,376 KB
testcase_24 AC 20 ms
4,796 KB
testcase_25 AC 121 ms
4,380 KB
testcase_26 AC 83 ms
4,716 KB
testcase_27 AC 123 ms
4,376 KB
testcase_28 AC 76 ms
4,772 KB
testcase_29 AC 160 ms
5,704 KB
testcase_30 AC 20 ms
4,376 KB
testcase_31 AC 26 ms
4,380 KB
testcase_32 AC 43 ms
4,376 KB
testcase_33 AC 132 ms
4,864 KB
testcase_34 AC 10 ms
4,380 KB
testcase_35 AC 143 ms
4,380 KB
testcase_36 AC 108 ms
5,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,K; cin >> N >> K;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    vector<ll> a_sum(N + 1, 0);
    rep(i,N) a_sum[i + 1] = a_sum[i] + a[i];
    vector<ll> S;
    rep(i,N-K+1) S.push_back(a_sum[i + K] - a_sum[i]);
    sort(S.begin(), S.end());

    int Q; cin >> Q;
    rep(_,Q) {
        ll x; cin >> x;
        auto it = upper_bound(S.begin(), S.end(), x);
        cout << (it - S.begin()) << endl;
    }
}
0