結果

問題 No.1890 Many Sequences Sum Queries
ユーザー CleyLCleyL
提出日時 2023-07-05 13:44:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 78,544 KB
実行使用メモリ 4,968 KB
最終ジャッジ日時 2023-09-26 13:33:18
合計ジャッジ時間 3,292 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 178 ms
4,968 KB
testcase_01 AC 177 ms
4,952 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 68 ms
4,792 KB
testcase_08 AC 16 ms
4,836 KB
testcase_09 AC 20 ms
4,840 KB
testcase_10 AC 175 ms
4,840 KB
testcase_11 AC 85 ms
4,848 KB
testcase_12 AC 123 ms
4,840 KB
testcase_13 AC 128 ms
4,908 KB
testcase_14 AC 70 ms
4,836 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  long long n,q;cin>>n>>q;
  vector<long long> A(n), B,C;
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  C.push_back(0);
  for(int i = 0; n > i; i++){
    for(int j = 1; A[i] >= j; j++){
      B.push_back(j);
      C.push_back(C[C.size()-1]+B[B.size()-1]);
    }
  }
  for(int i = 0; q > i; i++){
    long long x;cin>>x;
    auto ans = lower_bound(C.begin(),C.end(),x)-C.begin();
    if(ans == C.size()){
      cout << -1 << endl;
    }else{
      cout << ans << endl;
    }
  }
}
0