#include <bits/stdc++.h>
using namespace std;
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi>
#define vp vector<pii>
#define sp << " " <<
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back
const int inf = 1e18;
const int MOD = 998244353;
const int N = 3e5+1;
class Compare {
public:
bool operator()(pair<int,pii> a, pair<int,pii> b){
if(a.ff == b.ff)return a.ss.ff > b.ss.ff;
return a.ff < b.ff;
}
};
void solve() {
int n,m,q;
cin >> n >> m >> q;
if (n <= 300000) {
priority_queue<pair<int,pii>,vector<pair<int,pii>>,Compare> pq;
vi full(n+1,0);
vi ans(n+1);
int c = 1;
for (int i=1;i<=m;i++) {
cin >> ans[i];
full[ans[i]] =1;
}
for (int i=1;i<=n;) {
if (full[i]) {
i++;
continue;
}
int j = i;
while (!full[j]) j++;
j--;
pq.push({j-i+1,{i,j}});
i=j+1;
}
for (int i=m+1;i<=n;i++) {
auto f = pq.top();
pq.pop();
int l = f.ss.first;
int r = f.ss.ss;
int mid = (l+r) >> 1;
if (l <= mid-1){
pq.push({mid-l,{l,mid-1}});
}
if(mid+1<=r){
pq.push({r-mid,{mid+1,r}});
}
ans[i] = mid;
//cout << mid << endl;
}
while (q--) {
int ind;
cin >> ind;
cout << ans[ind] << endl;
}
}
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef Local
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
Compilation message
ogledala.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
3 | #pragma optimize "DostSeferoğlu"
|
ogledala.cpp: In function 'void solve()':
ogledala.cpp:40:9: warning: unused variable 'c' [-Wunused-variable]
40 | int c = 1;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Runtime error |
4 ms |
4440 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |