# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
618775 |
2022-08-02T07:24:54 Z |
Je_O |
OGLEDALA (COI15_ogledala) |
C++17 |
|
64 ms |
14916 KB |
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, pair<ll, ll>> iii;
const int N = 3e5 + 5;
ll a[N], b[N], ans[N];
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int m, n, q; cin >> m >> n >> q;
for(int i = 1; i <= n; ++i)cin >> a[i];
for(int i = 1; i <= q; ++i)cin >> b[i];
for(int i = 1; i <= n; ++i)ans[i] = a[i];
priority_queue<iii> pq;
if(a[1] > 1)pq.push(mp(a[1] - 1, mp(-1, -(a[1] - 1))));
for(int i = 1; i < n; ++i){
if(a[i] + 1 < a[i + 1]){
pq.push(mp(a[i + 1] - a[i] - 1, mp(-(a[i] + 1), -(a[i + 1] - 1))));
}
}
if(a[n] < m)pq.push(mp(m - a[n], mp(-(a[n] + 1), -m)));
for(int i = n + 1; i < N; ++i){
iii cur = pq.top(); pq.pop();
ans[i] = -cur.se.fi + (cur.fi - 1)/2;
if(-cur.se.fi < ans[i]){
pq.push(mp(ans[i] - (-cur.se.fi), mp(cur.se.fi, -(ans[i] - 1))));
}
if(ans[i] < -cur.se.se){
pq.push(mp(-cur.se.se - ans[i], mp(-(ans[i] + 1), cur.se.se)));
}
}
for(int i = 1; i <= q; ++i){
cout << ans[b[i]] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2668 KB |
Output is correct |
3 |
Correct |
28 ms |
5088 KB |
Output is correct |
4 |
Correct |
26 ms |
5180 KB |
Output is correct |
5 |
Correct |
55 ms |
7840 KB |
Output is correct |
6 |
Correct |
53 ms |
8156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
14800 KB |
Output is correct |
2 |
Correct |
54 ms |
14916 KB |
Output is correct |
3 |
Runtime error |
33 ms |
468 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
33 ms |
448 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |