結果

問題 No.1890 Many Sequences Sum Queries
ユーザー HIcoderHIcoder
提出日時 2023-07-14 17:01:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 1,101 ms
コンパイル使用メモリ 112,340 KB
実行使用メモリ 4,604 KB
最終ジャッジ日時 2023-10-14 06:42:28
合計ジャッジ時間 4,913 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
4,376 KB
testcase_01 AC 175 ms
4,440 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 66 ms
4,440 KB
testcase_08 AC 15 ms
4,376 KB
testcase_09 AC 19 ms
4,452 KB
testcase_10 AC 174 ms
4,604 KB
testcase_11 AC 85 ms
4,380 KB
testcase_12 AC 119 ms
4,372 KB
testcase_13 AC 126 ms
4,368 KB
testcase_14 AC 68 ms
4,400 KB
testcase_15 AC 2 ms
4,372 KB
testcase_16 AC 2 ms
4,372 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 1 ms
4,368 KB
testcase_19 AC 2 ms
4,372 KB
testcase_20 AC 2 ms
4,372 KB
testcase_21 AC 2 ms
4,372 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,368 KB
testcase_25 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set> 
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include <unordered_set>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;

int main(){
    int N,Q;
    cin>>N>>Q;
    vector<int> A(N);
    vector<int> B;
    for(int i=0;i<N;i++){
        cin>>A[i];
        for(int j=1;j<=A[i];j++){
            B.push_back(j);
        }
    }
    int n=B.size();
    vector<ll> sumB(n);
    sumB[0]=B[0];
    for(int i=1;i<n;i++){
        sumB[i]=sumB[i-1]+B[i];
    }

    for(int q=0;q<Q;q++){
        ll S;
        cin>>S;
        auto it=lower_bound(sumB.begin(),sumB.end(),S);

        if(it==sumB.end()){
            cout<<-1<<endl;
        }else{
            int c=it-sumB.begin();
            cout<<c+1<<endl;

        }

    }

}
0