#include <bits/stdc++.h>
#include "towers.h"
using namespace std;
const long long inf=1e18;
long long n,a[100069];
void init(int on,vector<int> aa)
{
long long i;
n=on;
for(i=1;i<=n;i++)
{
a[i]=aa[i-1];
}
}
int max_towers(int lb,int rb,int cw)
{
long long i,l=inf,c=0;
lb++;
rb++;
for(i=lb;i<=rb;i++)
{
if(c%2==0)
{
if(a[i]<=l-cw)
{
c++;
l=a[i];
}
else if(a[i]>l)
{
l=a[i];
}
}
else
{
if(a[i]>=l+cw)
{
c++;
l=a[i];
}
else if(a[i]<l)
{
l=a[i];
}
}
}
return (c+1)/2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1236 ms |
1368 KB |
Output is correct |
2 |
Execution timed out |
4011 ms |
1868 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
504 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
504 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
8 ms |
1224 KB |
Output is correct |
37 |
Correct |
10 ms |
1872 KB |
Output is correct |
38 |
Correct |
11 ms |
2036 KB |
Output is correct |
39 |
Correct |
13 ms |
1876 KB |
Output is correct |
40 |
Correct |
11 ms |
1868 KB |
Output is correct |
41 |
Correct |
11 ms |
1868 KB |
Output is correct |
42 |
Correct |
10 ms |
1868 KB |
Output is correct |
43 |
Correct |
10 ms |
1872 KB |
Output is correct |
44 |
Correct |
9 ms |
1868 KB |
Output is correct |
45 |
Correct |
10 ms |
1876 KB |
Output is correct |
46 |
Correct |
10 ms |
1868 KB |
Output is correct |
47 |
Correct |
12 ms |
1880 KB |
Output is correct |
48 |
Correct |
14 ms |
1868 KB |
Output is correct |
49 |
Correct |
12 ms |
1864 KB |
Output is correct |
50 |
Correct |
10 ms |
1868 KB |
Output is correct |
51 |
Correct |
9 ms |
2136 KB |
Output is correct |
52 |
Correct |
10 ms |
1868 KB |
Output is correct |
53 |
Correct |
10 ms |
1880 KB |
Output is correct |
54 |
Correct |
11 ms |
1864 KB |
Output is correct |
55 |
Correct |
11 ms |
1868 KB |
Output is correct |
56 |
Correct |
11 ms |
1868 KB |
Output is correct |
57 |
Correct |
12 ms |
1852 KB |
Output is correct |
58 |
Correct |
10 ms |
1836 KB |
Output is correct |
59 |
Correct |
10 ms |
2064 KB |
Output is correct |
60 |
Correct |
10 ms |
1872 KB |
Output is correct |
61 |
Correct |
10 ms |
1860 KB |
Output is correct |
62 |
Correct |
10 ms |
1872 KB |
Output is correct |
63 |
Correct |
10 ms |
1844 KB |
Output is correct |
64 |
Correct |
10 ms |
1868 KB |
Output is correct |
65 |
Correct |
10 ms |
1868 KB |
Output is correct |
66 |
Correct |
10 ms |
1868 KB |
Output is correct |
67 |
Correct |
10 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4038 ms |
1864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2775 ms |
788 KB |
Output is correct |
2 |
Execution timed out |
4089 ms |
1848 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
504 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
344 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
8 ms |
1224 KB |
Output is correct |
37 |
Correct |
10 ms |
1872 KB |
Output is correct |
38 |
Correct |
11 ms |
2036 KB |
Output is correct |
39 |
Correct |
13 ms |
1876 KB |
Output is correct |
40 |
Correct |
11 ms |
1868 KB |
Output is correct |
41 |
Correct |
11 ms |
1868 KB |
Output is correct |
42 |
Correct |
10 ms |
1868 KB |
Output is correct |
43 |
Correct |
10 ms |
1872 KB |
Output is correct |
44 |
Correct |
9 ms |
1868 KB |
Output is correct |
45 |
Correct |
10 ms |
1876 KB |
Output is correct |
46 |
Correct |
10 ms |
1868 KB |
Output is correct |
47 |
Correct |
12 ms |
1880 KB |
Output is correct |
48 |
Correct |
14 ms |
1868 KB |
Output is correct |
49 |
Correct |
12 ms |
1864 KB |
Output is correct |
50 |
Correct |
10 ms |
1868 KB |
Output is correct |
51 |
Correct |
9 ms |
2136 KB |
Output is correct |
52 |
Correct |
10 ms |
1868 KB |
Output is correct |
53 |
Correct |
10 ms |
1880 KB |
Output is correct |
54 |
Correct |
11 ms |
1864 KB |
Output is correct |
55 |
Correct |
11 ms |
1868 KB |
Output is correct |
56 |
Correct |
11 ms |
1868 KB |
Output is correct |
57 |
Correct |
12 ms |
1852 KB |
Output is correct |
58 |
Correct |
10 ms |
1836 KB |
Output is correct |
59 |
Correct |
10 ms |
2064 KB |
Output is correct |
60 |
Correct |
10 ms |
1872 KB |
Output is correct |
61 |
Correct |
10 ms |
1860 KB |
Output is correct |
62 |
Correct |
10 ms |
1872 KB |
Output is correct |
63 |
Correct |
10 ms |
1844 KB |
Output is correct |
64 |
Correct |
10 ms |
1868 KB |
Output is correct |
65 |
Correct |
10 ms |
1868 KB |
Output is correct |
66 |
Correct |
10 ms |
1868 KB |
Output is correct |
67 |
Correct |
10 ms |
1868 KB |
Output is correct |
68 |
Execution timed out |
4038 ms |
1864 KB |
Time limit exceeded |
69 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1236 ms |
1368 KB |
Output is correct |
2 |
Execution timed out |
4011 ms |
1868 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |