#include "towers.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
#define ff first
#define ss second
const int DEBUG=0;
const int N = 100100;
const int inf = 2e9;
int h[N];
// arvore para achar os indices l' e r':
struct value{
int mn,mx,best,best2;
value(){
mn = inf,mx=-inf,best=best2=-inf;
}
value operator+(const value &o)const{
value res;
res.mn = min(mn,o.mn);
res.mx = max(mx,o.mx);
res.best = max({best,o.best,o.mx - mn});
res.best2 = max({best2,o.best2,mx - o.mn});
return res;
}
};
int n;
struct node{
value v;
node *l,*r;
node(){
l=r=NULL;
}
void build(int i,int j,int h[]){
if(i == j){
v.mn = v.mx = h[i];
v.best = v.best2 = 0;
l = r = NULL;
return;
}
l = new node();
r = new node();
int m = (i+j)/2;
l->build(i,m,h);
r->build(m+1,j,h);
v = l->v + r->v;
}
// achar maior dif no segmento
value qry(int i,int j,int a,int b){
if(a == i && j == b)return v;
int m = (i+j)/2;
if(b<=m)return l->qry(i,m,a,b);
if(a > m)return r->qry(m+1,j,a,b);
return l->qry(i,m,a,m) + r->qry(m+1,j,m+1,b);
}
// achar maior L tal que H[L] >= X, e L <= R
int last(int i,int j,int X,int R){ // lembrar de passar (1,n,A[i]+D,i-1)
if(i>R)return -1;
if(v.mx < X)return -1;
if(i==j)return i;
int m = (i+j)/2;
int op1 = r->last(m+1,j,X,R);
if(op1!=-1)return op1;
return l->last(i,m,X,R);
}
int first(int i,int j,int X,int L){
if(j<L)return -1;
if(v.mx < X)return -1;
if(i==j)return i;
int m = (i+j)/2;
int op1 = l->first(i,m,X,L);
if(op1!=-1)return op1;
return r->first(m+1,j,X,L);
}
int good2(int n,int j,int R,int D){
int pos = first(1,n,h[j] + D,j+1);
if(pos == -1 || pos > R)return 0;
value v = qry(1,n,pos,R);
if(v.best2 >= D)return 1;
return 0;
}
int good(int n,int i,int L,int D){
int pos = last(1,n,h[i] + D,i-1);
if(pos==-1 || pos < L)return 0;
value v = qry(1,n,L,pos);
if(v.best >= D)return 1;
return 0;
}
int tot(int i,int j,int L,int R,int D){
return good(n,i,L,D) + good2(n,j,R,D);
}
};
node *difTree;
struct Node{
Node *l,*r;
int s=0;
Node(){
s=0,l=r=NULL;
}
};
void build(Node* no,int i,int j){
if(i == j){
return;
}
int m = (i+j)/2;
no->l = new Node();
no->r = new Node();
build(no->l,i,m),build(no->r,m+1,j);
}
void upd(Node *old,Node *nv,int i,int j,int p){
if(i == j){
nv->s = old->s ^ 1;
return;
}
int m = (i+j)/2;
if(p<=m){
nv->r = old->r;
nv->l = new Node();
upd(old->l,nv->l,i,m,p);
}else{
nv->l = old->l;
nv->r = new Node();
upd(old->r,nv->r,m+1,j,p);
}
nv->s = nv->l->s + nv->r->s;
}
int first(Node *no,int i,int j,int L,int R){
if(no->s == 0 || i > R || j < L)return -1;
if(i == j)return i;
int m = (i+j)/2;
int op1 = first(no->l,i,m,L,R);
if(op1!=-1)return op1;
return first(no->r,m+1,j,L,R);
}
int last(Node *no,int i,int j,int L,int R){
if(no->s == 0 || i > R || j < L)return -1;
if(i == j)return i;
int m = (i+j)/2;
int op1 = last(no->r,m+1,j,L,R);
if(op1!=-1)return op1;
return last(no->l,i,m,L,R);
}
int query(Node *no,int i,int j,int a,int b){
if(i > j || i>b || j < a)return 0;
if(a<=i && j<=b)return no->s;
int m = (i+j)/2;
return query(no->l,i,m,a,b) + query(no->r,m+1,j,a,b);
}
Node *seg[N];
set<piii> diffs; // {id, {mx_antes - mn, mx_dps - mn}}
set<pii> small; // {dif, id}
// id<0 quer dizer que é dif de id com id-1. se n com id+1
vector<int> delta; // D validos
void init(int N, std::vector<int> H) {
n=N;
h[0] = inf;
rep(i,1,n+1)h[i] = H[i-1];
h[n+1] = inf;
difTree = new node();
difTree->build(1,n,h);
seg[0] = new Node();
build(seg[0],1,n);
piii curDif = {0,{inf,0}};
for(int i=1;i<=n+1;i++){
if(h[i] < min(h[i-1],h[i+1])){
// v
curDif.ff = i;
curDif.ss.ff-=h[i];
curDif.ss.ss=-h[i];
}
if(h[i] > max(h[i-1],h[i+1])){
// ^
curDif.ss.ss+=h[i];
diffs.insert(curDif);
curDif.ss.ff=h[i];
}
}
int seg_id = 0;
delta.pb(0);
for(auto it : diffs){
Node *no = new Node();
upd(seg[0],no,1,n,it.ff);
small.insert({it.ss.ff,-it.ff}); // dif de it.ff com it.ff-1
small.insert({it.ss.ss,it.ff}); // dif de it.ff com it.ff+1
seg[0] = no;
if(DEBUG)cout <<"upd "<<it.ff<<endl;
}
while(diffs.size() > 1){
pii mn = *small.begin();
auto it = diffs.lower_bound({abs(mn.ss),{-inf,-inf}}); // achar id mn.ss
piii curDif = *it;
if(DEBUG)cout << "upd "<<mn.ff<<" "<<abs(mn.ss) << endl;
if(delta.back()!=mn.first){
delta.pb(mn.first);
Node *no = new Node();
upd(seg[seg_id],no,1,n,abs(mn.ss));
seg[++seg_id] = no;
}else{
Node *no = new Node();
upd(seg[seg_id],no,1,n,abs(mn.ss));
seg[seg_id] = no;
}
if(mn.ss < 0){
// id com id-1:
piii ant = *--it;
diffs.erase(ant);
small.erase({ant.ss.ss,ant.ff});
ant.ss.ss += abs(curDif.ss.ss - curDif.ss.ff);// vale aumenta um pouco
small.insert({ant.ss.ss,ant.ff});
diffs.insert(ant);
}else{
piii nxt = *++it;
diffs.erase(nxt);
small.erase({nxt.ss.ff,-nxt.ff});
nxt.ss.ff += abs(curDif.ss.ss - curDif.ss.ff);// vale aumenta um pouco
small.insert({nxt.ss.ff,-nxt.ff});
diffs.insert(nxt);
}
diffs.erase(curDif);
small.erase({curDif.ss.ff,-curDif.ff});
small.erase({curDif.ss.ss,curDif.ff});
}
if(DEBUG)cout<<"DELTA\n";
for(auto it : delta)if(DEBUG)cout<<it<<" ";
if(DEBUG)cout << endl;
}
int max_towers(int L, int R, int D) {
L++,R++;
if(DEBUG)cout << "QUERY "<<L<<" "<<R<<" "<<D<<endl;
int posD = lower_bound(delta.begin(),delta.end(),D) - delta.begin();
if(posD == (int)delta.size())return 1;
int seg_ver = (posD-1);
if(DEBUG)cout << "POSD "<<posD<<" "<<seg_ver << endl;
int fi = first(seg[seg_ver],1,n,L,R);
int la = last(seg[seg_ver],1,n,L,R);
if(DEBUG)cout << "fi and la: "<<fi<<" "<<la<<endl;
if(fi > la || fi==-1 || la==-1){
value v = difTree->qry(1,n,L,R);
int tot=0;
if(v.best>=D)tot++;
if(v.best2>=D)tot++;
return max(1,tot);
}
return query(seg[seg_ver],1,n,fi,la) + difTree->tot(fi,la,L,R,D);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
481 ms |
10304 KB |
Output is correct |
2 |
Correct |
927 ms |
17096 KB |
Output is correct |
3 |
Correct |
920 ms |
17060 KB |
Output is correct |
4 |
Correct |
825 ms |
17076 KB |
Output is correct |
5 |
Correct |
828 ms |
17192 KB |
Output is correct |
6 |
Correct |
796 ms |
17024 KB |
Output is correct |
7 |
Correct |
952 ms |
17096 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
464 KB |
Output is correct |
2 |
Correct |
3 ms |
1104 KB |
Output is correct |
3 |
Correct |
2 ms |
1104 KB |
Output is correct |
4 |
Correct |
5 ms |
1360 KB |
Output is correct |
5 |
Correct |
4 ms |
1360 KB |
Output is correct |
6 |
Correct |
3 ms |
1360 KB |
Output is correct |
7 |
Correct |
4 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
1 ms |
648 KB |
Output is correct |
15 |
Correct |
3 ms |
1116 KB |
Output is correct |
16 |
Correct |
4 ms |
1360 KB |
Output is correct |
17 |
Correct |
5 ms |
1360 KB |
Output is correct |
18 |
Correct |
1 ms |
592 KB |
Output is correct |
19 |
Correct |
1 ms |
592 KB |
Output is correct |
20 |
Correct |
2 ms |
1104 KB |
Output is correct |
21 |
Correct |
4 ms |
1360 KB |
Output is correct |
22 |
Correct |
4 ms |
1360 KB |
Output is correct |
23 |
Correct |
1 ms |
592 KB |
Output is correct |
24 |
Correct |
1 ms |
592 KB |
Output is correct |
25 |
Correct |
1 ms |
592 KB |
Output is correct |
26 |
Correct |
3 ms |
1104 KB |
Output is correct |
27 |
Correct |
2 ms |
1104 KB |
Output is correct |
28 |
Correct |
3 ms |
1360 KB |
Output is correct |
29 |
Correct |
4 ms |
1360 KB |
Output is correct |
30 |
Correct |
4 ms |
1360 KB |
Output is correct |
31 |
Correct |
3 ms |
1360 KB |
Output is correct |
32 |
Correct |
1 ms |
592 KB |
Output is correct |
33 |
Correct |
1 ms |
592 KB |
Output is correct |
34 |
Correct |
1 ms |
592 KB |
Output is correct |
35 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
464 KB |
Output is correct |
2 |
Correct |
3 ms |
1104 KB |
Output is correct |
3 |
Correct |
2 ms |
1104 KB |
Output is correct |
4 |
Correct |
5 ms |
1360 KB |
Output is correct |
5 |
Correct |
4 ms |
1360 KB |
Output is correct |
6 |
Correct |
3 ms |
1360 KB |
Output is correct |
7 |
Correct |
4 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
1 ms |
648 KB |
Output is correct |
15 |
Correct |
3 ms |
1116 KB |
Output is correct |
16 |
Correct |
4 ms |
1360 KB |
Output is correct |
17 |
Correct |
5 ms |
1360 KB |
Output is correct |
18 |
Correct |
1 ms |
592 KB |
Output is correct |
19 |
Correct |
1 ms |
592 KB |
Output is correct |
20 |
Correct |
2 ms |
1104 KB |
Output is correct |
21 |
Correct |
4 ms |
1360 KB |
Output is correct |
22 |
Correct |
4 ms |
1360 KB |
Output is correct |
23 |
Correct |
1 ms |
592 KB |
Output is correct |
24 |
Correct |
1 ms |
592 KB |
Output is correct |
25 |
Correct |
1 ms |
592 KB |
Output is correct |
26 |
Correct |
3 ms |
1104 KB |
Output is correct |
27 |
Correct |
2 ms |
1104 KB |
Output is correct |
28 |
Correct |
3 ms |
1360 KB |
Output is correct |
29 |
Correct |
4 ms |
1360 KB |
Output is correct |
30 |
Correct |
4 ms |
1360 KB |
Output is correct |
31 |
Correct |
3 ms |
1360 KB |
Output is correct |
32 |
Correct |
1 ms |
592 KB |
Output is correct |
33 |
Correct |
1 ms |
592 KB |
Output is correct |
34 |
Correct |
1 ms |
592 KB |
Output is correct |
35 |
Correct |
1 ms |
592 KB |
Output is correct |
36 |
Correct |
128 ms |
35096 KB |
Output is correct |
37 |
Correct |
221 ms |
55584 KB |
Output is correct |
38 |
Correct |
261 ms |
55304 KB |
Output is correct |
39 |
Correct |
370 ms |
74568 KB |
Output is correct |
40 |
Correct |
376 ms |
74564 KB |
Output is correct |
41 |
Correct |
378 ms |
74660 KB |
Output is correct |
42 |
Correct |
399 ms |
74612 KB |
Output is correct |
43 |
Correct |
28 ms |
17060 KB |
Output is correct |
44 |
Correct |
33 ms |
17096 KB |
Output is correct |
45 |
Correct |
26 ms |
17056 KB |
Output is correct |
46 |
Correct |
27 ms |
17084 KB |
Output is correct |
47 |
Correct |
235 ms |
55364 KB |
Output is correct |
48 |
Correct |
363 ms |
74568 KB |
Output is correct |
49 |
Correct |
422 ms |
74664 KB |
Output is correct |
50 |
Correct |
36 ms |
17028 KB |
Output is correct |
51 |
Correct |
37 ms |
17064 KB |
Output is correct |
52 |
Correct |
210 ms |
55412 KB |
Output is correct |
53 |
Correct |
384 ms |
74792 KB |
Output is correct |
54 |
Correct |
389 ms |
74596 KB |
Output is correct |
55 |
Correct |
32 ms |
17064 KB |
Output is correct |
56 |
Correct |
27 ms |
17100 KB |
Output is correct |
57 |
Correct |
214 ms |
53500 KB |
Output is correct |
58 |
Correct |
221 ms |
55464 KB |
Output is correct |
59 |
Correct |
234 ms |
55588 KB |
Output is correct |
60 |
Correct |
414 ms |
74580 KB |
Output is correct |
61 |
Correct |
369 ms |
74592 KB |
Output is correct |
62 |
Correct |
347 ms |
74632 KB |
Output is correct |
63 |
Correct |
372 ms |
74584 KB |
Output is correct |
64 |
Correct |
26 ms |
17072 KB |
Output is correct |
65 |
Correct |
27 ms |
17080 KB |
Output is correct |
66 |
Correct |
28 ms |
17084 KB |
Output is correct |
67 |
Correct |
25 ms |
17064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1136 ms |
55064 KB |
Output is correct |
2 |
Correct |
1383 ms |
55408 KB |
Output is correct |
3 |
Correct |
1358 ms |
55584 KB |
Output is correct |
4 |
Correct |
1516 ms |
74588 KB |
Output is correct |
5 |
Correct |
1329 ms |
74676 KB |
Output is correct |
6 |
Correct |
1274 ms |
74616 KB |
Output is correct |
7 |
Correct |
1594 ms |
74684 KB |
Output is correct |
8 |
Correct |
866 ms |
17064 KB |
Output is correct |
9 |
Correct |
658 ms |
17096 KB |
Output is correct |
10 |
Correct |
1053 ms |
17136 KB |
Output is correct |
11 |
Correct |
870 ms |
17048 KB |
Output is correct |
12 |
Correct |
1068 ms |
17116 KB |
Output is correct |
13 |
Correct |
751 ms |
17096 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
1 ms |
592 KB |
Output is correct |
17 |
Correct |
249 ms |
55404 KB |
Output is correct |
18 |
Correct |
395 ms |
74600 KB |
Output is correct |
19 |
Correct |
379 ms |
74652 KB |
Output is correct |
20 |
Correct |
27 ms |
17052 KB |
Output is correct |
21 |
Correct |
28 ms |
17072 KB |
Output is correct |
22 |
Correct |
261 ms |
55368 KB |
Output is correct |
23 |
Correct |
407 ms |
74604 KB |
Output is correct |
24 |
Correct |
367 ms |
74660 KB |
Output is correct |
25 |
Correct |
26 ms |
17060 KB |
Output is correct |
26 |
Correct |
26 ms |
17096 KB |
Output is correct |
27 |
Correct |
3 ms |
1108 KB |
Output is correct |
28 |
Correct |
4 ms |
1360 KB |
Output is correct |
29 |
Correct |
3 ms |
1360 KB |
Output is correct |
30 |
Correct |
1 ms |
592 KB |
Output is correct |
31 |
Correct |
1 ms |
592 KB |
Output is correct |
32 |
Correct |
3 ms |
1104 KB |
Output is correct |
33 |
Correct |
4 ms |
1360 KB |
Output is correct |
34 |
Correct |
3 ms |
1360 KB |
Output is correct |
35 |
Correct |
1 ms |
592 KB |
Output is correct |
36 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
341 ms |
12468 KB |
Output is correct |
2 |
Correct |
1283 ms |
55492 KB |
Output is correct |
3 |
Correct |
1311 ms |
55436 KB |
Output is correct |
4 |
Correct |
1365 ms |
74600 KB |
Output is correct |
5 |
Correct |
1539 ms |
74840 KB |
Output is correct |
6 |
Correct |
1465 ms |
74560 KB |
Output is correct |
7 |
Correct |
1415 ms |
74680 KB |
Output is correct |
8 |
Correct |
922 ms |
17088 KB |
Output is correct |
9 |
Correct |
701 ms |
17072 KB |
Output is correct |
10 |
Correct |
1020 ms |
17096 KB |
Output is correct |
11 |
Correct |
1000 ms |
17064 KB |
Output is correct |
12 |
Correct |
231 ms |
55428 KB |
Output is correct |
13 |
Correct |
369 ms |
74564 KB |
Output is correct |
14 |
Correct |
373 ms |
74756 KB |
Output is correct |
15 |
Correct |
26 ms |
17088 KB |
Output is correct |
16 |
Correct |
26 ms |
17088 KB |
Output is correct |
17 |
Correct |
227 ms |
53548 KB |
Output is correct |
18 |
Correct |
224 ms |
55544 KB |
Output is correct |
19 |
Correct |
238 ms |
55620 KB |
Output is correct |
20 |
Correct |
374 ms |
74608 KB |
Output is correct |
21 |
Correct |
353 ms |
74724 KB |
Output is correct |
22 |
Correct |
385 ms |
74580 KB |
Output is correct |
23 |
Correct |
383 ms |
74616 KB |
Output is correct |
24 |
Correct |
26 ms |
17096 KB |
Output is correct |
25 |
Correct |
27 ms |
17000 KB |
Output is correct |
26 |
Correct |
27 ms |
17056 KB |
Output is correct |
27 |
Correct |
26 ms |
17068 KB |
Output is correct |
28 |
Correct |
3 ms |
1104 KB |
Output is correct |
29 |
Correct |
4 ms |
1360 KB |
Output is correct |
30 |
Correct |
3 ms |
1360 KB |
Output is correct |
31 |
Correct |
1 ms |
592 KB |
Output is correct |
32 |
Correct |
1 ms |
592 KB |
Output is correct |
33 |
Correct |
1 ms |
592 KB |
Output is correct |
34 |
Correct |
4 ms |
1104 KB |
Output is correct |
35 |
Correct |
3 ms |
1104 KB |
Output is correct |
36 |
Correct |
3 ms |
1360 KB |
Output is correct |
37 |
Correct |
4 ms |
1360 KB |
Output is correct |
38 |
Correct |
4 ms |
1360 KB |
Output is correct |
39 |
Correct |
4 ms |
1360 KB |
Output is correct |
40 |
Correct |
1 ms |
592 KB |
Output is correct |
41 |
Correct |
1 ms |
592 KB |
Output is correct |
42 |
Correct |
1 ms |
592 KB |
Output is correct |
43 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
464 KB |
Output is correct |
2 |
Correct |
3 ms |
1104 KB |
Output is correct |
3 |
Correct |
2 ms |
1104 KB |
Output is correct |
4 |
Correct |
5 ms |
1360 KB |
Output is correct |
5 |
Correct |
4 ms |
1360 KB |
Output is correct |
6 |
Correct |
3 ms |
1360 KB |
Output is correct |
7 |
Correct |
4 ms |
1360 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
1 ms |
648 KB |
Output is correct |
15 |
Correct |
3 ms |
1116 KB |
Output is correct |
16 |
Correct |
4 ms |
1360 KB |
Output is correct |
17 |
Correct |
5 ms |
1360 KB |
Output is correct |
18 |
Correct |
1 ms |
592 KB |
Output is correct |
19 |
Correct |
1 ms |
592 KB |
Output is correct |
20 |
Correct |
2 ms |
1104 KB |
Output is correct |
21 |
Correct |
4 ms |
1360 KB |
Output is correct |
22 |
Correct |
4 ms |
1360 KB |
Output is correct |
23 |
Correct |
1 ms |
592 KB |
Output is correct |
24 |
Correct |
1 ms |
592 KB |
Output is correct |
25 |
Correct |
1 ms |
592 KB |
Output is correct |
26 |
Correct |
3 ms |
1104 KB |
Output is correct |
27 |
Correct |
2 ms |
1104 KB |
Output is correct |
28 |
Correct |
3 ms |
1360 KB |
Output is correct |
29 |
Correct |
4 ms |
1360 KB |
Output is correct |
30 |
Correct |
4 ms |
1360 KB |
Output is correct |
31 |
Correct |
3 ms |
1360 KB |
Output is correct |
32 |
Correct |
1 ms |
592 KB |
Output is correct |
33 |
Correct |
1 ms |
592 KB |
Output is correct |
34 |
Correct |
1 ms |
592 KB |
Output is correct |
35 |
Correct |
1 ms |
592 KB |
Output is correct |
36 |
Correct |
128 ms |
35096 KB |
Output is correct |
37 |
Correct |
221 ms |
55584 KB |
Output is correct |
38 |
Correct |
261 ms |
55304 KB |
Output is correct |
39 |
Correct |
370 ms |
74568 KB |
Output is correct |
40 |
Correct |
376 ms |
74564 KB |
Output is correct |
41 |
Correct |
378 ms |
74660 KB |
Output is correct |
42 |
Correct |
399 ms |
74612 KB |
Output is correct |
43 |
Correct |
28 ms |
17060 KB |
Output is correct |
44 |
Correct |
33 ms |
17096 KB |
Output is correct |
45 |
Correct |
26 ms |
17056 KB |
Output is correct |
46 |
Correct |
27 ms |
17084 KB |
Output is correct |
47 |
Correct |
235 ms |
55364 KB |
Output is correct |
48 |
Correct |
363 ms |
74568 KB |
Output is correct |
49 |
Correct |
422 ms |
74664 KB |
Output is correct |
50 |
Correct |
36 ms |
17028 KB |
Output is correct |
51 |
Correct |
37 ms |
17064 KB |
Output is correct |
52 |
Correct |
210 ms |
55412 KB |
Output is correct |
53 |
Correct |
384 ms |
74792 KB |
Output is correct |
54 |
Correct |
389 ms |
74596 KB |
Output is correct |
55 |
Correct |
32 ms |
17064 KB |
Output is correct |
56 |
Correct |
27 ms |
17100 KB |
Output is correct |
57 |
Correct |
214 ms |
53500 KB |
Output is correct |
58 |
Correct |
221 ms |
55464 KB |
Output is correct |
59 |
Correct |
234 ms |
55588 KB |
Output is correct |
60 |
Correct |
414 ms |
74580 KB |
Output is correct |
61 |
Correct |
369 ms |
74592 KB |
Output is correct |
62 |
Correct |
347 ms |
74632 KB |
Output is correct |
63 |
Correct |
372 ms |
74584 KB |
Output is correct |
64 |
Correct |
26 ms |
17072 KB |
Output is correct |
65 |
Correct |
27 ms |
17080 KB |
Output is correct |
66 |
Correct |
28 ms |
17084 KB |
Output is correct |
67 |
Correct |
25 ms |
17064 KB |
Output is correct |
68 |
Correct |
1136 ms |
55064 KB |
Output is correct |
69 |
Correct |
1383 ms |
55408 KB |
Output is correct |
70 |
Correct |
1358 ms |
55584 KB |
Output is correct |
71 |
Correct |
1516 ms |
74588 KB |
Output is correct |
72 |
Correct |
1329 ms |
74676 KB |
Output is correct |
73 |
Correct |
1274 ms |
74616 KB |
Output is correct |
74 |
Correct |
1594 ms |
74684 KB |
Output is correct |
75 |
Correct |
866 ms |
17064 KB |
Output is correct |
76 |
Correct |
658 ms |
17096 KB |
Output is correct |
77 |
Correct |
1053 ms |
17136 KB |
Output is correct |
78 |
Correct |
870 ms |
17048 KB |
Output is correct |
79 |
Correct |
1068 ms |
17116 KB |
Output is correct |
80 |
Correct |
751 ms |
17096 KB |
Output is correct |
81 |
Correct |
1 ms |
208 KB |
Output is correct |
82 |
Correct |
1 ms |
592 KB |
Output is correct |
83 |
Correct |
1 ms |
592 KB |
Output is correct |
84 |
Correct |
249 ms |
55404 KB |
Output is correct |
85 |
Correct |
395 ms |
74600 KB |
Output is correct |
86 |
Correct |
379 ms |
74652 KB |
Output is correct |
87 |
Correct |
27 ms |
17052 KB |
Output is correct |
88 |
Correct |
28 ms |
17072 KB |
Output is correct |
89 |
Correct |
261 ms |
55368 KB |
Output is correct |
90 |
Correct |
407 ms |
74604 KB |
Output is correct |
91 |
Correct |
367 ms |
74660 KB |
Output is correct |
92 |
Correct |
26 ms |
17060 KB |
Output is correct |
93 |
Correct |
26 ms |
17096 KB |
Output is correct |
94 |
Correct |
3 ms |
1108 KB |
Output is correct |
95 |
Correct |
4 ms |
1360 KB |
Output is correct |
96 |
Correct |
3 ms |
1360 KB |
Output is correct |
97 |
Correct |
1 ms |
592 KB |
Output is correct |
98 |
Correct |
1 ms |
592 KB |
Output is correct |
99 |
Correct |
3 ms |
1104 KB |
Output is correct |
100 |
Correct |
4 ms |
1360 KB |
Output is correct |
101 |
Correct |
3 ms |
1360 KB |
Output is correct |
102 |
Correct |
1 ms |
592 KB |
Output is correct |
103 |
Correct |
1 ms |
592 KB |
Output is correct |
104 |
Correct |
1335 ms |
48980 KB |
Output is correct |
105 |
Correct |
1371 ms |
55268 KB |
Output is correct |
106 |
Correct |
1639 ms |
55468 KB |
Output is correct |
107 |
Correct |
1612 ms |
74664 KB |
Output is correct |
108 |
Correct |
1641 ms |
74652 KB |
Output is correct |
109 |
Correct |
1635 ms |
74632 KB |
Output is correct |
110 |
Correct |
1588 ms |
74672 KB |
Output is correct |
111 |
Correct |
953 ms |
17096 KB |
Output is correct |
112 |
Correct |
792 ms |
17232 KB |
Output is correct |
113 |
Correct |
1111 ms |
17048 KB |
Output is correct |
114 |
Correct |
1024 ms |
17072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
481 ms |
10304 KB |
Output is correct |
2 |
Correct |
927 ms |
17096 KB |
Output is correct |
3 |
Correct |
920 ms |
17060 KB |
Output is correct |
4 |
Correct |
825 ms |
17076 KB |
Output is correct |
5 |
Correct |
828 ms |
17192 KB |
Output is correct |
6 |
Correct |
796 ms |
17024 KB |
Output is correct |
7 |
Correct |
952 ms |
17096 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
3 ms |
1104 KB |
Output is correct |
13 |
Correct |
2 ms |
1104 KB |
Output is correct |
14 |
Correct |
5 ms |
1360 KB |
Output is correct |
15 |
Correct |
4 ms |
1360 KB |
Output is correct |
16 |
Correct |
3 ms |
1360 KB |
Output is correct |
17 |
Correct |
4 ms |
1360 KB |
Output is correct |
18 |
Correct |
1 ms |
592 KB |
Output is correct |
19 |
Correct |
1 ms |
592 KB |
Output is correct |
20 |
Correct |
1 ms |
592 KB |
Output is correct |
21 |
Correct |
1 ms |
600 KB |
Output is correct |
22 |
Correct |
0 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
592 KB |
Output is correct |
24 |
Correct |
1 ms |
648 KB |
Output is correct |
25 |
Correct |
3 ms |
1116 KB |
Output is correct |
26 |
Correct |
4 ms |
1360 KB |
Output is correct |
27 |
Correct |
5 ms |
1360 KB |
Output is correct |
28 |
Correct |
1 ms |
592 KB |
Output is correct |
29 |
Correct |
1 ms |
592 KB |
Output is correct |
30 |
Correct |
2 ms |
1104 KB |
Output is correct |
31 |
Correct |
4 ms |
1360 KB |
Output is correct |
32 |
Correct |
4 ms |
1360 KB |
Output is correct |
33 |
Correct |
1 ms |
592 KB |
Output is correct |
34 |
Correct |
1 ms |
592 KB |
Output is correct |
35 |
Correct |
1 ms |
592 KB |
Output is correct |
36 |
Correct |
3 ms |
1104 KB |
Output is correct |
37 |
Correct |
2 ms |
1104 KB |
Output is correct |
38 |
Correct |
3 ms |
1360 KB |
Output is correct |
39 |
Correct |
4 ms |
1360 KB |
Output is correct |
40 |
Correct |
4 ms |
1360 KB |
Output is correct |
41 |
Correct |
3 ms |
1360 KB |
Output is correct |
42 |
Correct |
1 ms |
592 KB |
Output is correct |
43 |
Correct |
1 ms |
592 KB |
Output is correct |
44 |
Correct |
1 ms |
592 KB |
Output is correct |
45 |
Correct |
1 ms |
592 KB |
Output is correct |
46 |
Correct |
128 ms |
35096 KB |
Output is correct |
47 |
Correct |
221 ms |
55584 KB |
Output is correct |
48 |
Correct |
261 ms |
55304 KB |
Output is correct |
49 |
Correct |
370 ms |
74568 KB |
Output is correct |
50 |
Correct |
376 ms |
74564 KB |
Output is correct |
51 |
Correct |
378 ms |
74660 KB |
Output is correct |
52 |
Correct |
399 ms |
74612 KB |
Output is correct |
53 |
Correct |
28 ms |
17060 KB |
Output is correct |
54 |
Correct |
33 ms |
17096 KB |
Output is correct |
55 |
Correct |
26 ms |
17056 KB |
Output is correct |
56 |
Correct |
27 ms |
17084 KB |
Output is correct |
57 |
Correct |
235 ms |
55364 KB |
Output is correct |
58 |
Correct |
363 ms |
74568 KB |
Output is correct |
59 |
Correct |
422 ms |
74664 KB |
Output is correct |
60 |
Correct |
36 ms |
17028 KB |
Output is correct |
61 |
Correct |
37 ms |
17064 KB |
Output is correct |
62 |
Correct |
210 ms |
55412 KB |
Output is correct |
63 |
Correct |
384 ms |
74792 KB |
Output is correct |
64 |
Correct |
389 ms |
74596 KB |
Output is correct |
65 |
Correct |
32 ms |
17064 KB |
Output is correct |
66 |
Correct |
27 ms |
17100 KB |
Output is correct |
67 |
Correct |
214 ms |
53500 KB |
Output is correct |
68 |
Correct |
221 ms |
55464 KB |
Output is correct |
69 |
Correct |
234 ms |
55588 KB |
Output is correct |
70 |
Correct |
414 ms |
74580 KB |
Output is correct |
71 |
Correct |
369 ms |
74592 KB |
Output is correct |
72 |
Correct |
347 ms |
74632 KB |
Output is correct |
73 |
Correct |
372 ms |
74584 KB |
Output is correct |
74 |
Correct |
26 ms |
17072 KB |
Output is correct |
75 |
Correct |
27 ms |
17080 KB |
Output is correct |
76 |
Correct |
28 ms |
17084 KB |
Output is correct |
77 |
Correct |
25 ms |
17064 KB |
Output is correct |
78 |
Correct |
1136 ms |
55064 KB |
Output is correct |
79 |
Correct |
1383 ms |
55408 KB |
Output is correct |
80 |
Correct |
1358 ms |
55584 KB |
Output is correct |
81 |
Correct |
1516 ms |
74588 KB |
Output is correct |
82 |
Correct |
1329 ms |
74676 KB |
Output is correct |
83 |
Correct |
1274 ms |
74616 KB |
Output is correct |
84 |
Correct |
1594 ms |
74684 KB |
Output is correct |
85 |
Correct |
866 ms |
17064 KB |
Output is correct |
86 |
Correct |
658 ms |
17096 KB |
Output is correct |
87 |
Correct |
1053 ms |
17136 KB |
Output is correct |
88 |
Correct |
870 ms |
17048 KB |
Output is correct |
89 |
Correct |
1068 ms |
17116 KB |
Output is correct |
90 |
Correct |
751 ms |
17096 KB |
Output is correct |
91 |
Correct |
1 ms |
208 KB |
Output is correct |
92 |
Correct |
1 ms |
592 KB |
Output is correct |
93 |
Correct |
1 ms |
592 KB |
Output is correct |
94 |
Correct |
249 ms |
55404 KB |
Output is correct |
95 |
Correct |
395 ms |
74600 KB |
Output is correct |
96 |
Correct |
379 ms |
74652 KB |
Output is correct |
97 |
Correct |
27 ms |
17052 KB |
Output is correct |
98 |
Correct |
28 ms |
17072 KB |
Output is correct |
99 |
Correct |
261 ms |
55368 KB |
Output is correct |
100 |
Correct |
407 ms |
74604 KB |
Output is correct |
101 |
Correct |
367 ms |
74660 KB |
Output is correct |
102 |
Correct |
26 ms |
17060 KB |
Output is correct |
103 |
Correct |
26 ms |
17096 KB |
Output is correct |
104 |
Correct |
3 ms |
1108 KB |
Output is correct |
105 |
Correct |
4 ms |
1360 KB |
Output is correct |
106 |
Correct |
3 ms |
1360 KB |
Output is correct |
107 |
Correct |
1 ms |
592 KB |
Output is correct |
108 |
Correct |
1 ms |
592 KB |
Output is correct |
109 |
Correct |
3 ms |
1104 KB |
Output is correct |
110 |
Correct |
4 ms |
1360 KB |
Output is correct |
111 |
Correct |
3 ms |
1360 KB |
Output is correct |
112 |
Correct |
1 ms |
592 KB |
Output is correct |
113 |
Correct |
1 ms |
592 KB |
Output is correct |
114 |
Correct |
341 ms |
12468 KB |
Output is correct |
115 |
Correct |
1283 ms |
55492 KB |
Output is correct |
116 |
Correct |
1311 ms |
55436 KB |
Output is correct |
117 |
Correct |
1365 ms |
74600 KB |
Output is correct |
118 |
Correct |
1539 ms |
74840 KB |
Output is correct |
119 |
Correct |
1465 ms |
74560 KB |
Output is correct |
120 |
Correct |
1415 ms |
74680 KB |
Output is correct |
121 |
Correct |
922 ms |
17088 KB |
Output is correct |
122 |
Correct |
701 ms |
17072 KB |
Output is correct |
123 |
Correct |
1020 ms |
17096 KB |
Output is correct |
124 |
Correct |
1000 ms |
17064 KB |
Output is correct |
125 |
Correct |
231 ms |
55428 KB |
Output is correct |
126 |
Correct |
369 ms |
74564 KB |
Output is correct |
127 |
Correct |
373 ms |
74756 KB |
Output is correct |
128 |
Correct |
26 ms |
17088 KB |
Output is correct |
129 |
Correct |
26 ms |
17088 KB |
Output is correct |
130 |
Correct |
227 ms |
53548 KB |
Output is correct |
131 |
Correct |
224 ms |
55544 KB |
Output is correct |
132 |
Correct |
238 ms |
55620 KB |
Output is correct |
133 |
Correct |
374 ms |
74608 KB |
Output is correct |
134 |
Correct |
353 ms |
74724 KB |
Output is correct |
135 |
Correct |
385 ms |
74580 KB |
Output is correct |
136 |
Correct |
383 ms |
74616 KB |
Output is correct |
137 |
Correct |
26 ms |
17096 KB |
Output is correct |
138 |
Correct |
27 ms |
17000 KB |
Output is correct |
139 |
Correct |
27 ms |
17056 KB |
Output is correct |
140 |
Correct |
26 ms |
17068 KB |
Output is correct |
141 |
Correct |
3 ms |
1104 KB |
Output is correct |
142 |
Correct |
4 ms |
1360 KB |
Output is correct |
143 |
Correct |
3 ms |
1360 KB |
Output is correct |
144 |
Correct |
1 ms |
592 KB |
Output is correct |
145 |
Correct |
1 ms |
592 KB |
Output is correct |
146 |
Correct |
1 ms |
592 KB |
Output is correct |
147 |
Correct |
4 ms |
1104 KB |
Output is correct |
148 |
Correct |
3 ms |
1104 KB |
Output is correct |
149 |
Correct |
3 ms |
1360 KB |
Output is correct |
150 |
Correct |
4 ms |
1360 KB |
Output is correct |
151 |
Correct |
4 ms |
1360 KB |
Output is correct |
152 |
Correct |
4 ms |
1360 KB |
Output is correct |
153 |
Correct |
1 ms |
592 KB |
Output is correct |
154 |
Correct |
1 ms |
592 KB |
Output is correct |
155 |
Correct |
1 ms |
592 KB |
Output is correct |
156 |
Correct |
1 ms |
592 KB |
Output is correct |
157 |
Correct |
1335 ms |
48980 KB |
Output is correct |
158 |
Correct |
1371 ms |
55268 KB |
Output is correct |
159 |
Correct |
1639 ms |
55468 KB |
Output is correct |
160 |
Correct |
1612 ms |
74664 KB |
Output is correct |
161 |
Correct |
1641 ms |
74652 KB |
Output is correct |
162 |
Correct |
1635 ms |
74632 KB |
Output is correct |
163 |
Correct |
1588 ms |
74672 KB |
Output is correct |
164 |
Correct |
953 ms |
17096 KB |
Output is correct |
165 |
Correct |
792 ms |
17232 KB |
Output is correct |
166 |
Correct |
1111 ms |
17048 KB |
Output is correct |
167 |
Correct |
1024 ms |
17072 KB |
Output is correct |
168 |
Correct |
1 ms |
208 KB |
Output is correct |
169 |
Correct |
982 ms |
18400 KB |
Output is correct |
170 |
Correct |
1896 ms |
55236 KB |
Output is correct |
171 |
Correct |
1819 ms |
55336 KB |
Output is correct |
172 |
Correct |
1833 ms |
74668 KB |
Output is correct |
173 |
Correct |
2055 ms |
74612 KB |
Output is correct |
174 |
Correct |
1936 ms |
74624 KB |
Output is correct |
175 |
Correct |
1699 ms |
74552 KB |
Output is correct |
176 |
Correct |
737 ms |
17096 KB |
Output is correct |
177 |
Correct |
725 ms |
17064 KB |
Output is correct |
178 |
Correct |
1125 ms |
17060 KB |
Output is correct |
179 |
Correct |
721 ms |
17096 KB |
Output is correct |