結果
問題 |
No.1890 Many Sequences Sum Queries
|
ユーザー |
|
提出日時 | 2022-04-09 16:39:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 185 ms / 2,000 ms |
コード長 | 518 bytes |
コンパイル時間 | 3,059 ms |
コンパイル使用メモリ | 247,128 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 16:06:11 |
合計ジャッジ時間 | 6,233 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N, Q; cin >> N >> Q; vector<int> V = {0}; for (int i = 0; i < N; i++) { int a; cin >> a; for (int j = 1; j <= a; j++) V.push_back(V.back() + j); } for (int i = 0; i < Q; i++) { int s; cin >> s; auto it = lower_bound(V.begin(), V.end(), s); if (it == V.end()) cout << -1 << endl; else cout << it - V.begin() << endl; } }