Submission #72369655
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PII pair<ll,ll>
const int S = 1e9+50;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
void solve(){
ll n, q;
cin >> n >> q;
vector<ll>ma(n);
map<ll,ll>mp;
for(int i = 0; i < n; i++){
cin >> ma[i];
mp[ma[i]]++;
}
sort(ma.begin(),ma.end());
while(q--){
ll x, y;
cin >> x >> y;
ll u = x + y - 1;
ll a = lower_bound(ma.begin(),ma.end(),u) - ma.begin();
ll b = lower_bound(ma.begin(),ma.end(),x) - ma.begin();
ll c = a - b;
u = u + c;
if(mp[u] == 0){
cout << u << endl;
continue;
}
ll f = lower_bound(ma.begin(),ma.end(),u) - ma.begin();
for(int i = f; i < n; i++){
if(ma[i] != u){
u++;
break;
}
u++;
}
cout << u << endl;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
ll t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Forbidden List 2 |
| User | persuade123456 |
| Language | C++23 (GCC 15.2.0) |
| Score | 0 |
| Code Size | 949 Byte |
| Status | WA |
| Exec Time | > 2000 ms |
| Memory | 43132 KiB |
Judge Result
| Set Name | Sample | All | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | WA | 1 ms | 3580 KiB |
| 00-sample-02.txt | AC | 1 ms | 3636 KiB |
| 01-01.txt | AC | 8 ms | 4204 KiB |
| 01-02.txt | AC | 8 ms | 4052 KiB |
| 01-03.txt | WA | 7 ms | 4124 KiB |
| 01-04.txt | AC | 6 ms | 3772 KiB |
| 01-05.txt | WA | 5 ms | 4196 KiB |
| 01-06.txt | WA | 5 ms | 4216 KiB |
| 01-07.txt | WA | 4 ms | 3948 KiB |
| 01-08.txt | WA | 5 ms | 3796 KiB |
| 01-09.txt | WA | 5 ms | 4016 KiB |
| 01-10.txt | WA | 7 ms | 3796 KiB |
| 01-11.txt | WA | 5 ms | 3980 KiB |
| 01-12.txt | WA | 5 ms | 3852 KiB |
| 01-13.txt | WA | 360 ms | 35776 KiB |
| 01-14.txt | WA | 549 ms | 42796 KiB |
| 01-15.txt | WA | 584 ms | 43132 KiB |
| 01-16.txt | WA | 156 ms | 13248 KiB |
| 01-17.txt | WA | 543 ms | 30356 KiB |
| 01-18.txt | WA | 393 ms | 31148 KiB |
| 01-19.txt | TLE | > 2000 ms | 33488 KiB |
| 01-20.txt | WA | 370 ms | 27640 KiB |