結果

問題 No.1093 区間の和 / Sum of Range
ユーザー granddaifukugranddaifuku
提出日時 2020-06-25 20:43:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 875 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 170,724 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 22:58:26
合計ジャッジ時間 6,601 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 82 ms
4,376 KB
testcase_02 AC 40 ms
4,380 KB
testcase_03 AC 17 ms
4,376 KB
testcase_04 AC 13 ms
4,380 KB
testcase_05 AC 126 ms
4,380 KB
testcase_06 AC 24 ms
4,376 KB
testcase_07 AC 68 ms
4,376 KB
testcase_08 AC 52 ms
4,380 KB
testcase_09 AC 112 ms
4,380 KB
testcase_10 AC 56 ms
4,376 KB
testcase_11 AC 113 ms
4,380 KB
testcase_12 AC 62 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 123 ms
4,376 KB
testcase_15 AC 27 ms
4,380 KB
testcase_16 AC 144 ms
4,376 KB
testcase_17 AC 121 ms
4,380 KB
testcase_18 AC 77 ms
4,380 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 64 ms
4,380 KB
testcase_21 AC 142 ms
4,380 KB
testcase_22 AC 132 ms
4,380 KB
testcase_23 AC 101 ms
4,380 KB
testcase_24 AC 19 ms
4,380 KB
testcase_25 AC 123 ms
4,376 KB
testcase_26 AC 84 ms
4,376 KB
testcase_27 AC 129 ms
4,380 KB
testcase_28 AC 78 ms
4,376 KB
testcase_29 AC 160 ms
4,380 KB
testcase_30 AC 21 ms
4,376 KB
testcase_31 AC 26 ms
4,380 KB
testcase_32 AC 41 ms
4,380 KB
testcase_33 AC 133 ms
4,380 KB
testcase_34 AC 10 ms
4,376 KB
testcase_35 AC 141 ms
4,376 KB
testcase_36 AC 113 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, k, q;
    cin >> n >> k;
    vector<int> a(n + 1);
    rep (i, n) cin >> a[i + 1];
    rep (i, n) a[i + 1] += a[i];
    vector<int> s;
    rep (i, n + 1 - k) {
        int x = a[i + k] - a[i];
        s.push_back(x);
    }
    sort(s.begin(), s.end());
    cin >> q;
    rep (i, q) {
        int x;
        cin >> x;
        auto iter = upper_bound(s.begin(), s.end(), x);
        cout << (int)(iter - s.begin()) << endl;
    }
    
    return 0;
}

0