提出 #72359446


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vvvl=vector<vector<vector<long long>>>;
using pl=pair<long long,long long>;
using vpl=vector<pair<long long,long long>>;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(long long i=(long long)(a);i<(long long)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#include <atcoder/all>
using namespace atcoder;

long long modpow(long long a, long long n, long long mo){long long res=1;while(n>0){if(n&1){res=res*a%mo;}a=a*a%mo;n>>=1;}return res;}
long long Pow(long long a, long long n){long long res=1;while(n>0){if(n&1){res=res*a;}a=a*a;n>>=1;}return res;}

const ll MOD=998244353;
const ll INF=(1ll<<60);
int main(){
  ll N,Q;
  cin>>N>>Q;
  vl A(N);
  rep(i,N) cin>>A[i];
  sort(all(A));
  rep(ifdao,Q){
    ll x,y;
    cin>>x>>y;
    ll mem=lb(all(A),x)-A.begin();
    if(mem==N){
      cout<<x+y-1<<endl;
      continue;
    }
    y+=x-mem;
    x=0;
    //cout<<x<<" "<<y<<endl;
    ll left=0;
    ll right=INF;
    while(right-left>1){
      ll mid=(left+right)/2;
      ll me=lb(all(A),mid)-A.begin();
      if(mid-me>=y) right=mid;
      else left=mid;
    }
    cout<<left<<endl;
  }
}

提出情報

提出日時
問題 D - Forbidden List 2
ユーザ number_cat
言語 C++23 (GCC 15.2.0)
得点 400
コード長 1493 Byte
結果 AC
実行時間 891 ms
メモリ 5780 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 22
セット名 テストケース
Sample 00-sample-01.txt, 00-sample-02.txt
All 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt
ケース名 結果 実行時間 メモリ
00-sample-01.txt AC 1 ms 3640 KiB
00-sample-02.txt AC 1 ms 3480 KiB
01-01.txt AC 11 ms 3480 KiB
01-02.txt AC 13 ms 3580 KiB
01-03.txt AC 12 ms 3520 KiB
01-04.txt AC 11 ms 3568 KiB
01-05.txt AC 9 ms 3696 KiB
01-06.txt AC 10 ms 3580 KiB
01-07.txt AC 7 ms 3712 KiB
01-08.txt AC 8 ms 3632 KiB
01-09.txt AC 8 ms 3636 KiB
01-10.txt AC 7 ms 3576 KiB
01-11.txt AC 7 ms 3760 KiB
01-12.txt AC 8 ms 3520 KiB
01-13.txt AC 559 ms 5712 KiB
01-14.txt AC 863 ms 5780 KiB
01-15.txt AC 891 ms 5756 KiB
01-16.txt AC 378 ms 4176 KiB
01-17.txt AC 756 ms 5716 KiB
01-18.txt AC 592 ms 4820 KiB
01-19.txt AC 560 ms 5776 KiB
01-20.txt AC 545 ms 5720 KiB