結果
問題 | No.1890 Many Sequences Sum Queries |
ユーザー | matcharate12 |
提出日時 | 2022-03-28 16:12:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 653 bytes |
コンパイル時間 | 1,347 ms |
コンパイル使用メモリ | 167,636 KB |
実行使用メモリ | 17,848 KB |
最終ジャッジ日時 | 2024-05-04 00:16:16 |
合計ジャッジ時間 | 8,739 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) #define srep(i,a,b) for(int i = a; i < b; i++) #define all(A) (A).begin(),A.end() #define MOD 1000000007 using namespace std; using ll = long long; using P = pair<ll,ll>; using Graph = vector<vector<int>>; int siz(string s){return (int)s.size();} ll B[101010],S[101010]; int main(void){ int n,q; cin >> n >> q; int nn = 0; int p = 0; rep(i,n){ int a; cin >> a; nn += a; rep(j,a) B[p] = j+1,p++; } rep(i,q){ ll s; cin >> s; int ans = 0,t = 0; rep(j,nn+1){ if(t >= s) break; ans++; t += B[j]; } cout << (ans == nn+1 ? -1 : ans) << endl; } return 0; }