提出 #72373388


ソースコード 拡げる

#if !__INCLUDE_LEVEL__
#include __FILE__

void solve() {
  int N,Q;
  cin>>N>>Q;
  vl A(N);
  rep(i,N)cin>>A[i];
  sort(all(A));
  while(Q--){
    ll x,y;
    cin>>x>>y;
    ll d=lower_bound(all(A),x)-A.begin();
    ll l=x,r=3e9;
    while(r-l>1){
      ll mid=(r+l)/2;
      ll now=lower_bound(all(A),mid)-A.begin();
      if(mid-x+1-now+d>y)r=mid;
      else l=mid;
    }
    cout<<l<<el;
  }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)solve();
}

#else
#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint=modint998244353;
//using mint=modint1000000007;
  
// 関数テンプレート
template<typename T> bool chmax(T &m, const T q) {
    if (m < q) {m = q; return true;} else return false; }

template<typename T> bool chmin(T &m,const T q){
    if(m>q){m=q;return true;}else return false;
}
template<typename T>
bool grid_inside(const T h, const T w, const T &m, const T &n) {
    return (m >= 0 && m < h && n >= 0 && n < w);
}
// ループマクロ
#define rep(i,r) for(int i=0;(r)>i;i++)
#define REP(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,N) for(int i=(N)-1;i>=0;i--)
#define RREP(i,r,N) for(int i=(N)-1;i>=r;i--)

// コンテナショートカット
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define pb push_back
#define fixed15 std::fixed << std::setprecision(15)
// YES/NO 出力
#define Yes cout<<"Yes"<<el
#define No cout<<"No"<<el
#define YES cout<<"YES"<<el
#define NO cout<<"NO"<<el
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

// 型エイリアス
using ll=long long;
using ull=unsigned long long;
using pqgi=priority_queue<int, vector<int>, greater<int>>;
using pqgl=priority_queue<long long, vector<long long>, greater<long long>>;
using pqgpl=priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>>;
using pqgptpl=priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>>;
using pqi=priority_queue<int>;
using pii=pair<int, int>;
using tpi=tuple<int,int,int>;
using tpl=tuple<ll,ll,ll>;
using pll=pair<long long, long long>;
using vs=vector<string>;
using vi=vector<int>;
using vb=vector<bool>;
using vl=vector<long long>;
using vc=vector<char>;
using vvi=vector<vector<int>>;
using vvl=vector<vector<long long>>;
using vvc=vector<vector<char>>;
using vvb=vector<vector<bool>>;
using vvs=vector<vector<string>>;
using vpii=vector<pii>;
using vpll=vector<pll>;
using vvpii=vector<vector<pii>>;
using vvpll=vector<vector<pll>>;
using vtiii=vector<tuple<int, int, int>>;
using lb=long double;

// 定数
const long long INF=1e18;
const int mod=1e9+7;
//const int mod=998244353;
const int MAX=1e5+10;
const int MIN=-1e9;
const vpii dir={{1,0},{-1,0},{0,1},{0,-1}};
#endif


提出情報

提出日時
問題 D - Forbidden List 2
ユーザ yasaikeikaku
言語 C++23 (GCC 15.2.0)
得点 400
コード長 3149 Byte
結果 AC
実行時間 649 ms
メモリ 5800 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 3624 KiB
00-sample-02.txt AC 1 ms 3588 KiB
01-01.txt AC 3 ms 3608 KiB
01-02.txt AC 4 ms 3648 KiB
01-03.txt AC 4 ms 3648 KiB
01-04.txt AC 4 ms 3584 KiB
01-05.txt AC 5 ms 3716 KiB
01-06.txt AC 6 ms 3776 KiB
01-07.txt AC 3 ms 3576 KiB
01-08.txt AC 5 ms 3724 KiB
01-09.txt AC 6 ms 3708 KiB
01-10.txt AC 4 ms 3724 KiB
01-11.txt AC 4 ms 3804 KiB
01-12.txt AC 5 ms 3624 KiB
01-13.txt AC 392 ms 5740 KiB
01-14.txt AC 624 ms 5780 KiB
01-15.txt AC 649 ms 5800 KiB
01-16.txt AC 147 ms 4296 KiB
01-17.txt AC 587 ms 5712 KiB
01-18.txt AC 442 ms 4944 KiB
01-19.txt AC 277 ms 5792 KiB
01-20.txt AC 394 ms 5736 KiB