# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1027538 |
2024-07-19T07:24:24 Z |
정희우(#10953) |
Sushi (JOI16_sushi) |
C++17 |
|
6191 ms |
248780 KB |
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
using namespace std;
using lint = long long;
using intp = pair<int,int>;
using vint = vector<int>;
const int MAX_N=400010;
struct Seg
{
priority_queue<int> val;
priority_queue<int> lazy;
priority_queue<int> lazypop;
void lpop()
{
while(!lazypop.empty() && lazypop.top()==val.top())
{
lazypop.pop();
val.pop();
}
}
int push(int v)
{
int p=val.top();
if(p<=v)
return v;
val.pop();
val.push(v);
lpop();
lazy.push(v);
if(lazy.size()>val.size()-lazypop.size())
lazy.pop();
return p;
}
};
int n,q;
int initv[MAX_N];
Seg seg[MAX_N<<2];
void init_(int i,int s,int e)
{
for(int j=s;j<e;j++)
seg[i].val.push(initv[j]);
if(s+1==e)
return;
init_(i<<1,s,(s+e)>>1);
init_(i<<1|1,(s+e)>>1,e);
}
void update_lazy(Seg &p,Seg &l,Seg &r)
{
while(!p.lazy.empty())
{
int v=p.lazy.top();p.lazy.pop();
v=l.push(v);
r.push(v);
}
}
int update_(int i,int s,int e,int l,int r,int v)
{
if(s>=r || e<=l)
return v;
if(l<=s && e<=r)
{
int v2=seg[i].push(v);
return v2;
}
update_lazy(seg[i],seg[i<<1],seg[i<<1|1]);
int v1=update_(i<<1,s,(s+e)>>1,l,r,v);
int v2=update_(i<<1|1,(s+e)>>1,e,l,r,v1);
if(v!=v2)
{
seg[i].val.push(v);
seg[i].lazypop.push(v2);
seg[i].lpop();
}
return v2;
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> q;
for(int i=0;i<n;i++)
cin >> initv[i];
init_(1,0,n);
while(q--)
{
int s,t,p;
cin >> s >> t >> p;
if(s<=t)
p=update_(1,0,n,s-1,t,p);
else
{
p=update_(1,0,n,s-1,n,p);
p=update_(1,0,n,0,t,p);
}
cout << p << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
151120 KB |
Output is correct |
2 |
Correct |
49 ms |
151120 KB |
Output is correct |
3 |
Correct |
48 ms |
151128 KB |
Output is correct |
4 |
Correct |
55 ms |
151000 KB |
Output is correct |
5 |
Correct |
43 ms |
151132 KB |
Output is correct |
6 |
Correct |
44 ms |
151040 KB |
Output is correct |
7 |
Correct |
38 ms |
150876 KB |
Output is correct |
8 |
Correct |
40 ms |
151028 KB |
Output is correct |
9 |
Correct |
51 ms |
151164 KB |
Output is correct |
10 |
Correct |
44 ms |
151124 KB |
Output is correct |
11 |
Correct |
55 ms |
151120 KB |
Output is correct |
12 |
Correct |
56 ms |
151120 KB |
Output is correct |
13 |
Correct |
54 ms |
151132 KB |
Output is correct |
14 |
Correct |
44 ms |
151124 KB |
Output is correct |
15 |
Correct |
50 ms |
151072 KB |
Output is correct |
16 |
Correct |
39 ms |
151124 KB |
Output is correct |
17 |
Correct |
41 ms |
150616 KB |
Output is correct |
18 |
Correct |
35 ms |
150608 KB |
Output is correct |
19 |
Correct |
38 ms |
150620 KB |
Output is correct |
20 |
Correct |
36 ms |
150612 KB |
Output is correct |
21 |
Correct |
36 ms |
150596 KB |
Output is correct |
22 |
Correct |
38 ms |
150652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
271 ms |
212844 KB |
Output is correct |
2 |
Correct |
278 ms |
211560 KB |
Output is correct |
3 |
Correct |
251 ms |
209240 KB |
Output is correct |
4 |
Correct |
274 ms |
213088 KB |
Output is correct |
5 |
Correct |
278 ms |
212932 KB |
Output is correct |
6 |
Correct |
305 ms |
212932 KB |
Output is correct |
7 |
Correct |
311 ms |
212936 KB |
Output is correct |
8 |
Correct |
324 ms |
212932 KB |
Output is correct |
9 |
Correct |
195 ms |
209348 KB |
Output is correct |
10 |
Correct |
270 ms |
211700 KB |
Output is correct |
11 |
Correct |
213 ms |
209108 KB |
Output is correct |
12 |
Correct |
277 ms |
211664 KB |
Output is correct |
13 |
Correct |
275 ms |
212932 KB |
Output is correct |
14 |
Correct |
286 ms |
211492 KB |
Output is correct |
15 |
Correct |
241 ms |
209332 KB |
Output is correct |
16 |
Correct |
273 ms |
213096 KB |
Output is correct |
17 |
Correct |
274 ms |
213096 KB |
Output is correct |
18 |
Correct |
364 ms |
212940 KB |
Output is correct |
19 |
Correct |
313 ms |
213312 KB |
Output is correct |
20 |
Correct |
315 ms |
212936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
151120 KB |
Output is correct |
2 |
Correct |
49 ms |
151120 KB |
Output is correct |
3 |
Correct |
48 ms |
151128 KB |
Output is correct |
4 |
Correct |
55 ms |
151000 KB |
Output is correct |
5 |
Correct |
43 ms |
151132 KB |
Output is correct |
6 |
Correct |
44 ms |
151040 KB |
Output is correct |
7 |
Correct |
38 ms |
150876 KB |
Output is correct |
8 |
Correct |
40 ms |
151028 KB |
Output is correct |
9 |
Correct |
51 ms |
151164 KB |
Output is correct |
10 |
Correct |
44 ms |
151124 KB |
Output is correct |
11 |
Correct |
55 ms |
151120 KB |
Output is correct |
12 |
Correct |
56 ms |
151120 KB |
Output is correct |
13 |
Correct |
54 ms |
151132 KB |
Output is correct |
14 |
Correct |
44 ms |
151124 KB |
Output is correct |
15 |
Correct |
50 ms |
151072 KB |
Output is correct |
16 |
Correct |
39 ms |
151124 KB |
Output is correct |
17 |
Correct |
41 ms |
150616 KB |
Output is correct |
18 |
Correct |
35 ms |
150608 KB |
Output is correct |
19 |
Correct |
38 ms |
150620 KB |
Output is correct |
20 |
Correct |
36 ms |
150612 KB |
Output is correct |
21 |
Correct |
36 ms |
150596 KB |
Output is correct |
22 |
Correct |
38 ms |
150652 KB |
Output is correct |
23 |
Correct |
271 ms |
212844 KB |
Output is correct |
24 |
Correct |
278 ms |
211560 KB |
Output is correct |
25 |
Correct |
251 ms |
209240 KB |
Output is correct |
26 |
Correct |
274 ms |
213088 KB |
Output is correct |
27 |
Correct |
278 ms |
212932 KB |
Output is correct |
28 |
Correct |
305 ms |
212932 KB |
Output is correct |
29 |
Correct |
311 ms |
212936 KB |
Output is correct |
30 |
Correct |
324 ms |
212932 KB |
Output is correct |
31 |
Correct |
195 ms |
209348 KB |
Output is correct |
32 |
Correct |
270 ms |
211700 KB |
Output is correct |
33 |
Correct |
213 ms |
209108 KB |
Output is correct |
34 |
Correct |
277 ms |
211664 KB |
Output is correct |
35 |
Correct |
275 ms |
212932 KB |
Output is correct |
36 |
Correct |
286 ms |
211492 KB |
Output is correct |
37 |
Correct |
241 ms |
209332 KB |
Output is correct |
38 |
Correct |
273 ms |
213096 KB |
Output is correct |
39 |
Correct |
274 ms |
213096 KB |
Output is correct |
40 |
Correct |
364 ms |
212940 KB |
Output is correct |
41 |
Correct |
313 ms |
213312 KB |
Output is correct |
42 |
Correct |
315 ms |
212936 KB |
Output is correct |
43 |
Correct |
888 ms |
223796 KB |
Output is correct |
44 |
Correct |
1028 ms |
224200 KB |
Output is correct |
45 |
Correct |
276 ms |
211400 KB |
Output is correct |
46 |
Correct |
859 ms |
223940 KB |
Output is correct |
47 |
Correct |
929 ms |
223944 KB |
Output is correct |
48 |
Correct |
5902 ms |
238872 KB |
Output is correct |
49 |
Correct |
6191 ms |
238680 KB |
Output is correct |
50 |
Correct |
5585 ms |
238804 KB |
Output is correct |
51 |
Correct |
5570 ms |
238692 KB |
Output is correct |
52 |
Correct |
1000 ms |
224724 KB |
Output is correct |
53 |
Correct |
1004 ms |
224972 KB |
Output is correct |
54 |
Correct |
5204 ms |
238532 KB |
Output is correct |
55 |
Correct |
5597 ms |
238748 KB |
Output is correct |
56 |
Correct |
5323 ms |
238704 KB |
Output is correct |
57 |
Correct |
5409 ms |
238520 KB |
Output is correct |
58 |
Correct |
4682 ms |
236540 KB |
Output is correct |
59 |
Correct |
4614 ms |
235328 KB |
Output is correct |
60 |
Correct |
490 ms |
214476 KB |
Output is correct |
61 |
Correct |
503 ms |
214304 KB |
Output is correct |
62 |
Correct |
503 ms |
214472 KB |
Output is correct |
63 |
Correct |
593 ms |
214316 KB |
Output is correct |
64 |
Correct |
291 ms |
213012 KB |
Output is correct |
65 |
Correct |
346 ms |
212352 KB |
Output is correct |
66 |
Correct |
333 ms |
212168 KB |
Output is correct |
67 |
Correct |
1158 ms |
248780 KB |
Output is correct |
68 |
Correct |
1235 ms |
248732 KB |
Output is correct |
69 |
Correct |
1207 ms |
248620 KB |
Output is correct |
70 |
Correct |
1179 ms |
248620 KB |
Output is correct |