結果
問題 | No.1890 Many Sequences Sum Queries |
ユーザー | Luke02561 |
提出日時 | 2022-03-30 12:25:20 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 4,064 bytes |
コンパイル時間 | 2,685 ms |
コンパイル使用メモリ | 250,200 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-25 12:16:45 |
合計ジャッジ時間 | 4,742 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 162 ms
5,248 KB |
testcase_01 | AC | 167 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 65 ms
5,248 KB |
testcase_08 | AC | 15 ms
5,248 KB |
testcase_09 | AC | 19 ms
5,248 KB |
testcase_10 | AC | 168 ms
5,248 KB |
testcase_11 | AC | 79 ms
5,248 KB |
testcase_12 | AC | 113 ms
5,248 KB |
testcase_13 | AC | 121 ms
5,248 KB |
testcase_14 | AC | 64 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | AC | 2 ms
5,248 KB |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 1 ms
5,248 KB |
testcase_22 | AC | 1 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
ソースコード
#include"bits/stdc++.h" #include<experimental/iterator> #define rep(i,n) for(ll i=0;i<n;++i) #define ALL(x) x.begin(),x.end() #define BACK(x) x.rbegin(),x.rend() #define MOD1 1000000007 #define MOD2 998244353 #define INF INT_MAX #define INFL (LLONG_MAX / 2) #define FLOAT_ANS setprecision(30) #define TORAD(x) (x*acos(-1)/180.0) #define TODEG(x) (x*180/acos(-1)) using namespace std; using ll = long long; using ull = unsigned long long; template<typename T> // T:重み using p_que = priority_queue<T,vector<T>,greater<T>>; template<typename T> bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;} template<typename T> bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;} ll modpow(ll a, ll n, ll mod) {ll res=1;while (n>0) {if(n&1)res=(res*(a%mod))%mod;a=((a%mod)*(a%mod))%mod;n>>=1;}return res;} template<typename T> void RotateVec2(vector<vector<T>>&v){ll h=v.size();ll w=v[0].size();vector<vector<T>>t(w,vector<T>(h));rep(i,h){rep(j,w){t[j][h-i-1]=v[i][j];}}v=t;} bool InRange(ll x, ll mn, ll mx){return (mn <= x && x <= mx);} template<typename T> void printVec(vector<T>&v,string str=" "){copy(ALL(v),experimental::make_ostream_joiner(cout, str));} template<typename T> vector<T>&merged(vector<T>&a,vector<T>&b) {vector<T>res;merge(a.begin(),a.end(),b.begin(),b.end(),back_inserter(res));return res;} struct UnionFind{ vector<ll>tree; UnionFind(ll x):tree(x, -1){} ll root(ll x){if(tree[x]<0) return x;return tree[x]=root(tree[x]);} bool same(ll x,ll y){return root(x)==root(y);} ll size(ll x){return -tree[root(x)];} void unite(ll x,ll y){x=root(x),y=root(y);if(x==y)return;if(size(x)<size(y))swap(x,y);tree[x]+=tree[y];tree[y]=x;} }; template<typename T> struct SegTree{ ll e,n;vector<T>tree;function<T(T,T)>f; SegTree(ll n_,function<T(T,T)>f_,T e_=0):e(e_),f(f_){ll x=1;while(x<n_)x*=2;n=x;tree.assign(n*2,e);} void update(ll idx,T x){idx+=n-1;tree[idx]=x;while(idx){idx=(idx-1)/2;tree[idx]=f(tree[idx*2+1],tree[idx*2+2]);}} T query(ll x,ll y){return query_sub(x,y,0,n,0);} T query_sub(ll x,ll y,ll l,ll r,ll k){if(r<=x||y<=l)return e;if(x<=l&&r<=y)return tree[k];ll c1=query_sub(x,y,l,(l+r)/2,k*2+1);ll c2=query_sub(x,y,(l+r)/2,r,k*2+2);return f(c1,c2);} void print(){cout<<"---"<<endl;for(ll idx=0,t=1;auto i:tree){if(idx+1==n*2)break;cout<<i<<" ";++idx;if(idx+1==1<<t){++t;cout<<endl;}}cout<<"---"<<endl;} }; template <std::uint_fast64_t Modulus> class modint { using u64 = std::uint_fast64_t; public: u64 a; constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr modint operator+(const modint rhs) const noexcept {return modint(*this) += rhs;} constexpr modint operator-(const modint rhs) const noexcept {return modint(*this) -= rhs;} constexpr modint operator*(const modint rhs) const noexcept {return modint(*this) *= rhs;} constexpr modint operator/(const modint rhs) const noexcept {return modint(*this) /= rhs;} constexpr modint &operator+=(const modint rhs) noexcept {a += rhs.a;if (a >= Modulus) {a -= Modulus;}return *this;} constexpr modint &operator-=(const modint rhs) noexcept {if (a < rhs.a) {a += Modulus;}a -= rhs.a;return *this;} constexpr modint &operator*=(const modint rhs) noexcept {a = a * rhs.a % Modulus;return *this;} constexpr modint &operator/=(modint rhs) noexcept {u64 exp = Modulus - 2;while (exp) {if (exp % 2) {*this *= rhs;}rhs *= rhs;exp /= 2;}return *this;} constexpr modint &operator=(u64 x){ a = x % Modulus; return *this; } }; // MAIN PROGRAM ------------ int main(){ ll n, q; cin >> n >> q; vector<ll>b; b.push_back(0); rep(i, n) { ll a; cin >> a; rep(j, a) { b.push_back(b.back() + j + 1); } } rep(idx, q) { ll s; cin >> s; auto itr = lower_bound(ALL(b), s); if(itr == b.end()) cout << -1 << endl; else cout << itr - b.begin() << endl; } }