# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
692952 |
2023-02-02T07:46:15 Z |
Pyqe |
Catfish Farm (IOI22_fish) |
C++17 |
|
715 ms |
43956 KB |
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
#define mp make_pair
#define fr first
#define sc second
const long long inf=1e18;
long long mxa[100069][2];
vector<pair<long long,long long>> vl[100069];
struct segtree
{
long long l,r,mx;
segtree *p[2];
void bd(long long lh,long long rh)
{
l=lh;
r=rh;
mx=-inf;
if(l<r)
{
long long ii,md=(l+r)/2;
for(ii=0;ii<2;ii++)
{
p[ii]=new segtree;
p[ii]->bd(!ii?l:md+1,!ii?md:r);
}
}
}
void ud(long long x,long long w)
{
if(l>x||r<x);
else if(l>=x&&r<=x)
{
mx=max(mx,w);
}
else
{
long long ii;
for(ii=0;ii<2;ii++)
{
p[ii]->ud(x,w);
}
mx=max(p[0]->mx,p[1]->mx);
}
}
long long qr(long long lh,long long rh)
{
if(l>rh||r<lh)
{
return -inf;
}
else if(l>=lh&&r<=rh)
{
return mx;
}
else
{
return max(p[0]->qr(lh,rh),p[1]->qr(lh,rh));
}
}
}
sg[2];
long long max_weights(int n,int m,vector<int> xa,vector<int> ya,vector<int> wg)
{
long long i,j,ii,x,y,w,l,l2,sz,z=-inf;
for(i=1;i<=m;i++)
{
x=xa[i-1]+1;
y=ya[i-1]+1;
w=wg[i-1];
vl[x].push_back({y,w});
}
for(ii=0;ii<2;ii++)
{
sg[ii].bd(1,n);
}
for(i=1;i<=n;i++)
{
sort(vl[i].begin(),vl[i].end());
l=mxa[i-1][1];
l2=-inf;
if(i-2>=0)
{
l2=max(mxa[i-2][0],mxa[i-2][1]);
}
sz=vl[i].size();
for(j=0;j<sz;j++)
{
y=vl[i][j].fr;
w=vl[i][j].sc;
sg[0].ud(y,max(sg[0].qr(1,y-1),max(l,l2))+w);
}
for(j=sz-1;j>=0;j--)
{
y=vl[i][j].fr;
w=vl[i][j].sc;
sg[1].ud(y,max(sg[1].qr(y+1,n),l2)+w);
}
for(ii=0;ii<2;ii++)
{
mxa[i][ii]=max(mxa[i-1][ii],sg[ii].mx);
}
}
z=max(mxa[n][1],mxa[n-1][0]);
return z;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
24416 KB |
Output is correct |
2 |
Correct |
111 ms |
28636 KB |
Output is correct |
3 |
Correct |
26 ms |
22932 KB |
Output is correct |
4 |
Correct |
23 ms |
22896 KB |
Output is correct |
5 |
Correct |
299 ms |
41044 KB |
Output is correct |
6 |
Correct |
715 ms |
43908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
154 ms |
27584 KB |
Output is correct |
3 |
Correct |
192 ms |
34292 KB |
Output is correct |
4 |
Correct |
87 ms |
25532 KB |
Output is correct |
5 |
Correct |
137 ms |
28560 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
21 ms |
22976 KB |
Output is correct |
11 |
Correct |
30 ms |
22988 KB |
Output is correct |
12 |
Correct |
99 ms |
25556 KB |
Output is correct |
13 |
Correct |
110 ms |
28636 KB |
Output is correct |
14 |
Correct |
85 ms |
25440 KB |
Output is correct |
15 |
Correct |
91 ms |
28132 KB |
Output is correct |
16 |
Correct |
83 ms |
25484 KB |
Output is correct |
17 |
Correct |
89 ms |
27992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
22988 KB |
Output is correct |
2 |
Correct |
21 ms |
22988 KB |
Output is correct |
3 |
Correct |
60 ms |
24720 KB |
Output is correct |
4 |
Correct |
55 ms |
25488 KB |
Output is correct |
5 |
Correct |
89 ms |
30048 KB |
Output is correct |
6 |
Correct |
82 ms |
29412 KB |
Output is correct |
7 |
Correct |
82 ms |
29948 KB |
Output is correct |
8 |
Correct |
81 ms |
29984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2656 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2656 KB |
Output is correct |
10 |
Correct |
3 ms |
2848 KB |
Output is correct |
11 |
Correct |
4 ms |
2644 KB |
Output is correct |
12 |
Correct |
3 ms |
2704 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2656 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2656 KB |
Output is correct |
10 |
Correct |
3 ms |
2848 KB |
Output is correct |
11 |
Correct |
4 ms |
2644 KB |
Output is correct |
12 |
Correct |
3 ms |
2704 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2772 KB |
Output is correct |
15 |
Correct |
3 ms |
2644 KB |
Output is correct |
16 |
Correct |
4 ms |
2900 KB |
Output is correct |
17 |
Correct |
35 ms |
4912 KB |
Output is correct |
18 |
Correct |
54 ms |
5500 KB |
Output is correct |
19 |
Correct |
26 ms |
5360 KB |
Output is correct |
20 |
Correct |
25 ms |
5416 KB |
Output is correct |
21 |
Correct |
26 ms |
5476 KB |
Output is correct |
22 |
Correct |
51 ms |
7820 KB |
Output is correct |
23 |
Correct |
8 ms |
3284 KB |
Output is correct |
24 |
Correct |
20 ms |
4436 KB |
Output is correct |
25 |
Correct |
2 ms |
2688 KB |
Output is correct |
26 |
Correct |
6 ms |
3180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2656 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2656 KB |
Output is correct |
10 |
Correct |
3 ms |
2848 KB |
Output is correct |
11 |
Correct |
4 ms |
2644 KB |
Output is correct |
12 |
Correct |
3 ms |
2704 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2772 KB |
Output is correct |
15 |
Correct |
3 ms |
2644 KB |
Output is correct |
16 |
Correct |
4 ms |
2900 KB |
Output is correct |
17 |
Correct |
35 ms |
4912 KB |
Output is correct |
18 |
Correct |
54 ms |
5500 KB |
Output is correct |
19 |
Correct |
26 ms |
5360 KB |
Output is correct |
20 |
Correct |
25 ms |
5416 KB |
Output is correct |
21 |
Correct |
26 ms |
5476 KB |
Output is correct |
22 |
Correct |
51 ms |
7820 KB |
Output is correct |
23 |
Correct |
8 ms |
3284 KB |
Output is correct |
24 |
Correct |
20 ms |
4436 KB |
Output is correct |
25 |
Correct |
2 ms |
2688 KB |
Output is correct |
26 |
Correct |
6 ms |
3180 KB |
Output is correct |
27 |
Correct |
4 ms |
3360 KB |
Output is correct |
28 |
Correct |
127 ms |
14000 KB |
Output is correct |
29 |
Correct |
214 ms |
17512 KB |
Output is correct |
30 |
Correct |
223 ms |
16728 KB |
Output is correct |
31 |
Correct |
230 ms |
16936 KB |
Output is correct |
32 |
Correct |
173 ms |
18696 KB |
Output is correct |
33 |
Correct |
255 ms |
16924 KB |
Output is correct |
34 |
Correct |
288 ms |
16672 KB |
Output is correct |
35 |
Correct |
75 ms |
9120 KB |
Output is correct |
36 |
Correct |
216 ms |
18652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
22988 KB |
Output is correct |
2 |
Correct |
21 ms |
22988 KB |
Output is correct |
3 |
Correct |
60 ms |
24720 KB |
Output is correct |
4 |
Correct |
55 ms |
25488 KB |
Output is correct |
5 |
Correct |
89 ms |
30048 KB |
Output is correct |
6 |
Correct |
82 ms |
29412 KB |
Output is correct |
7 |
Correct |
82 ms |
29948 KB |
Output is correct |
8 |
Correct |
81 ms |
29984 KB |
Output is correct |
9 |
Correct |
128 ms |
29732 KB |
Output is correct |
10 |
Correct |
97 ms |
19364 KB |
Output is correct |
11 |
Correct |
192 ms |
36340 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
3 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
2664 KB |
Output is correct |
15 |
Correct |
7 ms |
2656 KB |
Output is correct |
16 |
Correct |
4 ms |
2656 KB |
Output is correct |
17 |
Correct |
3 ms |
2660 KB |
Output is correct |
18 |
Correct |
19 ms |
22896 KB |
Output is correct |
19 |
Correct |
19 ms |
22964 KB |
Output is correct |
20 |
Correct |
24 ms |
22972 KB |
Output is correct |
21 |
Correct |
19 ms |
22896 KB |
Output is correct |
22 |
Correct |
204 ms |
30112 KB |
Output is correct |
23 |
Correct |
184 ms |
36284 KB |
Output is correct |
24 |
Correct |
197 ms |
36836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
24416 KB |
Output is correct |
2 |
Correct |
111 ms |
28636 KB |
Output is correct |
3 |
Correct |
26 ms |
22932 KB |
Output is correct |
4 |
Correct |
23 ms |
22896 KB |
Output is correct |
5 |
Correct |
299 ms |
41044 KB |
Output is correct |
6 |
Correct |
715 ms |
43908 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
154 ms |
27584 KB |
Output is correct |
9 |
Correct |
192 ms |
34292 KB |
Output is correct |
10 |
Correct |
87 ms |
25532 KB |
Output is correct |
11 |
Correct |
137 ms |
28560 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
21 ms |
22976 KB |
Output is correct |
17 |
Correct |
30 ms |
22988 KB |
Output is correct |
18 |
Correct |
99 ms |
25556 KB |
Output is correct |
19 |
Correct |
110 ms |
28636 KB |
Output is correct |
20 |
Correct |
85 ms |
25440 KB |
Output is correct |
21 |
Correct |
91 ms |
28132 KB |
Output is correct |
22 |
Correct |
83 ms |
25484 KB |
Output is correct |
23 |
Correct |
89 ms |
27992 KB |
Output is correct |
24 |
Correct |
21 ms |
22988 KB |
Output is correct |
25 |
Correct |
21 ms |
22988 KB |
Output is correct |
26 |
Correct |
60 ms |
24720 KB |
Output is correct |
27 |
Correct |
55 ms |
25488 KB |
Output is correct |
28 |
Correct |
89 ms |
30048 KB |
Output is correct |
29 |
Correct |
82 ms |
29412 KB |
Output is correct |
30 |
Correct |
82 ms |
29948 KB |
Output is correct |
31 |
Correct |
81 ms |
29984 KB |
Output is correct |
32 |
Correct |
3 ms |
2644 KB |
Output is correct |
33 |
Correct |
1 ms |
2656 KB |
Output is correct |
34 |
Correct |
2 ms |
2644 KB |
Output is correct |
35 |
Correct |
2 ms |
2644 KB |
Output is correct |
36 |
Correct |
2 ms |
2652 KB |
Output is correct |
37 |
Correct |
2 ms |
2644 KB |
Output is correct |
38 |
Correct |
2 ms |
2644 KB |
Output is correct |
39 |
Correct |
2 ms |
2652 KB |
Output is correct |
40 |
Correct |
2 ms |
2656 KB |
Output is correct |
41 |
Correct |
3 ms |
2848 KB |
Output is correct |
42 |
Correct |
4 ms |
2644 KB |
Output is correct |
43 |
Correct |
3 ms |
2704 KB |
Output is correct |
44 |
Correct |
2 ms |
2644 KB |
Output is correct |
45 |
Correct |
2 ms |
2772 KB |
Output is correct |
46 |
Correct |
3 ms |
2644 KB |
Output is correct |
47 |
Correct |
4 ms |
2900 KB |
Output is correct |
48 |
Correct |
35 ms |
4912 KB |
Output is correct |
49 |
Correct |
54 ms |
5500 KB |
Output is correct |
50 |
Correct |
26 ms |
5360 KB |
Output is correct |
51 |
Correct |
25 ms |
5416 KB |
Output is correct |
52 |
Correct |
26 ms |
5476 KB |
Output is correct |
53 |
Correct |
51 ms |
7820 KB |
Output is correct |
54 |
Correct |
8 ms |
3284 KB |
Output is correct |
55 |
Correct |
20 ms |
4436 KB |
Output is correct |
56 |
Correct |
2 ms |
2688 KB |
Output is correct |
57 |
Correct |
6 ms |
3180 KB |
Output is correct |
58 |
Correct |
4 ms |
3360 KB |
Output is correct |
59 |
Correct |
127 ms |
14000 KB |
Output is correct |
60 |
Correct |
214 ms |
17512 KB |
Output is correct |
61 |
Correct |
223 ms |
16728 KB |
Output is correct |
62 |
Correct |
230 ms |
16936 KB |
Output is correct |
63 |
Correct |
173 ms |
18696 KB |
Output is correct |
64 |
Correct |
255 ms |
16924 KB |
Output is correct |
65 |
Correct |
288 ms |
16672 KB |
Output is correct |
66 |
Correct |
75 ms |
9120 KB |
Output is correct |
67 |
Correct |
216 ms |
18652 KB |
Output is correct |
68 |
Correct |
128 ms |
29732 KB |
Output is correct |
69 |
Correct |
97 ms |
19364 KB |
Output is correct |
70 |
Correct |
192 ms |
36340 KB |
Output is correct |
71 |
Correct |
2 ms |
2644 KB |
Output is correct |
72 |
Correct |
3 ms |
2652 KB |
Output is correct |
73 |
Correct |
3 ms |
2664 KB |
Output is correct |
74 |
Correct |
7 ms |
2656 KB |
Output is correct |
75 |
Correct |
4 ms |
2656 KB |
Output is correct |
76 |
Correct |
3 ms |
2660 KB |
Output is correct |
77 |
Correct |
19 ms |
22896 KB |
Output is correct |
78 |
Correct |
19 ms |
22964 KB |
Output is correct |
79 |
Correct |
24 ms |
22972 KB |
Output is correct |
80 |
Correct |
19 ms |
22896 KB |
Output is correct |
81 |
Correct |
204 ms |
30112 KB |
Output is correct |
82 |
Correct |
184 ms |
36284 KB |
Output is correct |
83 |
Correct |
197 ms |
36836 KB |
Output is correct |
84 |
Correct |
324 ms |
38884 KB |
Output is correct |
85 |
Correct |
321 ms |
40384 KB |
Output is correct |
86 |
Correct |
566 ms |
41576 KB |
Output is correct |
87 |
Correct |
522 ms |
43956 KB |
Output is correct |
88 |
Correct |
2 ms |
2644 KB |
Output is correct |
89 |
Correct |
594 ms |
43824 KB |
Output is correct |
90 |
Correct |
224 ms |
42676 KB |
Output is correct |
91 |
Correct |
276 ms |
42156 KB |
Output is correct |