結果

問題 No.1093 区間の和 / Sum of Range
ユーザー KKT89KKT89
提出日時 2020-06-27 10:40:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 89,280 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 19:12:54
合計ジャッジ時間 5,833 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 85 ms
4,376 KB
testcase_02 AC 42 ms
4,376 KB
testcase_03 AC 17 ms
4,384 KB
testcase_04 AC 13 ms
4,376 KB
testcase_05 AC 129 ms
4,376 KB
testcase_06 AC 25 ms
4,376 KB
testcase_07 AC 70 ms
4,380 KB
testcase_08 AC 52 ms
4,376 KB
testcase_09 AC 116 ms
4,380 KB
testcase_10 AC 59 ms
4,376 KB
testcase_11 AC 117 ms
4,376 KB
testcase_12 AC 63 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 128 ms
4,380 KB
testcase_15 AC 29 ms
4,376 KB
testcase_16 AC 146 ms
4,376 KB
testcase_17 AC 124 ms
4,376 KB
testcase_18 AC 81 ms
4,376 KB
testcase_19 AC 7 ms
4,380 KB
testcase_20 AC 66 ms
4,380 KB
testcase_21 AC 148 ms
4,376 KB
testcase_22 AC 138 ms
4,376 KB
testcase_23 AC 106 ms
4,380 KB
testcase_24 AC 19 ms
4,376 KB
testcase_25 AC 128 ms
4,376 KB
testcase_26 AC 86 ms
4,380 KB
testcase_27 AC 135 ms
4,376 KB
testcase_28 AC 81 ms
4,380 KB
testcase_29 AC 166 ms
4,380 KB
testcase_30 AC 21 ms
4,376 KB
testcase_31 AC 26 ms
4,380 KB
testcase_32 AC 43 ms
4,376 KB
testcase_33 AC 136 ms
4,380 KB
testcase_34 AC 10 ms
4,376 KB
testcase_35 AC 147 ms
4,376 KB
testcase_36 AC 114 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    vector<int> v;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        if(i>=k){
            sum-=a[i-k];
        }
        if(i>=k-1){
            v.push_back(sum);
        }
    }
    sort(v.begin(), v.end());
    int q; cin >> q;
    while(q--){
        int x; cin >> x;
        cout << upper_bound(v.begin(), v.end(),x)-v.begin() << endl;
    }
}
0