結果
問題 | No.1890 Many Sequences Sum Queries |
ユーザー | matcharate12 |
提出日時 | 2022-03-28 16:09:19 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 671 bytes |
コンパイル時間 | 1,849 ms |
コンパイル使用メモリ | 166,208 KB |
実行使用メモリ | 13,888 KB |
最終ジャッジ日時 | 2024-05-04 00:16:25 |
合計ジャッジ時間 | 9,220 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,991 ms
13,888 KB |
testcase_01 | TLE | - |
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,nn+1) S[i+1] = S[i]+B[i]; rep(i,q){ ll s; cin >> s; int ans = 0; rep(j,nn+1){ if(S[ans] >= s) break; ans++; } cout << (ans == nn+1 ? -1 : ans) << endl; } return 0; }