結果

問題 No.1093 区間の和 / Sum of Range
ユーザー NoviNovi
提出日時 2020-07-24 14:44:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 927 bytes
コンパイル時間 1,790 ms
コンパイル使用メモリ 172,424 KB
実行使用メモリ 5,208 KB
最終ジャッジ日時 2023-09-07 08:46:44
合計ジャッジ時間 9,711 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 18 ms
5,068 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 63 ms
4,392 KB
testcase_13 WA -
testcase_14 AC 121 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 118 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 140 ms
4,376 KB
testcase_22 AC 131 ms
4,468 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 157 ms
5,208 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 143 ms
4,376 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vector<int> a(n,0);
    rep(i,n) cin>>a[i];
    int q; cin>>q;
    vector<Int> sum_a(n+1,0);
    sum_a[0]=0;
    for(int i=0; i<n-1; i++){
        sum_a[i+1]=sum_a[i]+a[i+1];
    }
    vector<Int> S;
    for(int i=1; i<=n-k+1; i++){
        Int tmp=sum_a[i+k-1]-sum_a[i-1];
        S.emplace_back(tmp);
    }
    sort(S.begin(),S.end());    
    rep(i,q){
        Int x; cin>>x;
        auto d= upper_bound(S.begin(),S.end(),x);
        cout<<distance(S.begin(),d)<<endl;
    }
    return 0;
}
0