結果

問題 No.1093 区間の和 / Sum of Range
ユーザー motmot
提出日時 2020-07-02 18:43:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 941 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 88,996 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 03:57:36
合計ジャッジ時間 9,124 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 104 ms
4,352 KB
testcase_02 AC 49 ms
4,348 KB
testcase_03 AC 31 ms
4,352 KB
testcase_04 AC 28 ms
4,352 KB
testcase_05 AC 152 ms
4,348 KB
testcase_06 AC 32 ms
4,352 KB
testcase_07 AC 86 ms
4,352 KB
testcase_08 AC 73 ms
4,348 KB
testcase_09 AC 132 ms
4,348 KB
testcase_10 AC 78 ms
4,348 KB
testcase_11 AC 128 ms
4,348 KB
testcase_12 AC 77 ms
4,348 KB
testcase_13 AC 3 ms
4,352 KB
testcase_14 AC 137 ms
4,348 KB
testcase_15 AC 35 ms
4,352 KB
testcase_16 AC 159 ms
4,348 KB
testcase_17 AC 131 ms
4,352 KB
testcase_18 AC 88 ms
4,352 KB
testcase_19 AC 10 ms
4,352 KB
testcase_20 AC 73 ms
4,352 KB
testcase_21 AC 160 ms
4,352 KB
testcase_22 AC 158 ms
4,348 KB
testcase_23 AC 115 ms
4,352 KB
testcase_24 AC 34 ms
4,352 KB
testcase_25 AC 139 ms
4,352 KB
testcase_26 AC 102 ms
4,348 KB
testcase_27 AC 147 ms
4,352 KB
testcase_28 AC 95 ms
4,348 KB
testcase_29 AC 200 ms
4,348 KB
testcase_30 AC 25 ms
4,348 KB
testcase_31 AC 34 ms
4,348 KB
testcase_32 AC 52 ms
4,348 KB
testcase_33 AC 156 ms
4,348 KB
testcase_34 AC 12 ms
4,348 KB
testcase_35 AC 161 ms
4,352 KB
testcase_36 AC 136 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, K;
  cin>>N>>K;
  int a[N];
  for(int i=0;i<N;++i) cin>>a[i];
  vector<int> S;
  int tmp = 0;
  for(int i=0;i<K;++i){
    tmp += a[i];
  }
  S.push_back(tmp);
  for(int i=K;i<N;++i){
    tmp -= a[i-K];
    tmp += a[i];
    S.push_back(tmp);
  }
  sort(S.begin(), S.end());
  int Q;
  cin>>Q;
  int x;
  int ans[Q];
  for(int i=0;i<Q;++i){
    cin>>x;
    ans[i] = upper_bound(S.begin(), S.end(), x) - S.begin();
  }
  for(int i=0;i<Q;++i){
    cout<<ans[i]<<endl;
  }
}
0