CSES - Datatähti 2020 loppu - Results
Submission details
Task:Riippuliito
Sender:Hermanni Huhtamäki
Submission time:2020-02-09 16:29:25 +0200
Language:C++11
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#40.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#60.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#8ACCEPTED0.05 s2, 3details
#9ACCEPTED0.05 s2, 3details
#10ACCEPTED0.05 s2, 3details
#110.05 s2, 3details
#12ACCEPTED0.05 s2, 3details
#130.05 s2, 3details
#14ACCEPTED0.05 s2, 3details
#15--3details
#16--3details
#17--3details
#18--3details
#19--3details
#20--3details
#21--3details
#22ACCEPTED0.01 s1, 2, 3details
#23ACCEPTED0.01 s1, 2, 3details
#24ACCEPTED0.01 s1, 2, 3details
#25ACCEPTED0.01 s1, 2, 3details
#26ACCEPTED0.01 s1, 2, 3details
#27ACCEPTED0.01 s1, 2, 3details
#28ACCEPTED0.01 s1, 2, 3details
#290.01 s1, 2, 3details

Code

#include<bits/stdc++.h>

using namespace std;

int main()
{

int n;
cin >> n;

int h[n];
int m[n];
for (int i = 0; i < n; i++)
{
cin >> h[i];
}

int suunta = 0;
bool b[n+1], T = 0, Te = 0;
for (int i = 0; i < n; i++)
{
b[i] = 1;
m[i] = 0;
}
b[n] = 0;

int s = -1, S = -1;
int p = 0, P = -1;
int q = 0, Q = 0;

for (int j = 0; j < n; j++)
{
for (int i = 0; i < n; i++)
{
while (b[i] == 1)
{
m[i]++;
if (h[i] >= S) 
{
S = h[i];
P = i;
//cout << p << endl;
}
if (h[i] > s) 
{
s = h[i];
p = i;
//cout << p << endl;
}
i++;
}
s = -1;
S = -1;
if (b[p] == 0) continue;

b[p] = 0;
m[p]--;

//
if (P != p)
{
for (int x = p + 1; x<=P; x++)
{
if (m[P] > m[x] + 1)
{
suunta = 1;
break;
}
else if (m[P] > m[x])
{
suunta = 2;
break;
}
if (m[P] > m[x] + 1)
{
suunta += 3;
break;
}
else if (m[P] > m[x])
{
suunta += 6;
break;
}

}

q = p;
Q = P;
if (suunta == 6 || suunta == 8)
{
T = 1;
for (int x = p + 1; x<P; x++)
{
if (h[x] == h[p])
{
q = x;
T = 0;
break;
}
}
}
if (suunta == 2 || suunta == 8)
{
Te = 1;
for (int x = P - 1; x>p; x++)
{
if (h[x] == h[p])
{
Q = x;
Te = 0;
break;
}
}
}

if (T == 0 && Te ==0)
{
int we = q+1;
if (suunta != 2 && suunta != 8)
{
Q = n;
}
if (suunta != 6 && suunta != 8)
{
we = 0;
}
for ( ; we <= Q; we++)
{
m[we]--;
}
}


for (int x = p + 1; x<=P; x++)
{
if (h[x] == h[p])
{
b[x] = 0;
m[x]--;
}
}

}
//

}
s = -1;
for (int i = 0; i < n; i++)
{
//cout << m[i] << " ";
//cout << b[i] << " b:";
}
//cout << endl;
}

int v = 0;
for (int i = 0; i < n; i++)
{
if (m[i] > v) v = m[i];
//cout << m[i] << " ";
//cout << b[i] << endl;
}
cout << v+1 << endl;
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
10
1 1 1 1 1 1 1 1 1 1

correct output
1

user output
1

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
10
1 2 3 4 5 6 7 8 9 10

correct output
10

user output
10

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
10
10 9 8 7 6 5 4 3 2 1

correct output
10

user output
10

Test 4

Group: 1, 2, 3

Verdict:

input
10
10 9 6 10 10 3 6 7 6 5

correct output
4

user output
3

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
10
51 90 27 98 85 47 14 55 82 52

correct output
6

user output
6

Test 6

Group: 1, 2, 3

Verdict:

input
10
9 65 90 86 45 52 52 95 40 85

correct output
5

user output
4

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
10
3 46 77 16 59 32 22 41 87 89

correct output
7

user output
7

Test 8

Group: 2, 3

Verdict: ACCEPTED

input
5000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1

user output
1

Test 9

Group: 2, 3

Verdict: ACCEPTED

input
5000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
5000

user output
5000

Test 10

Group: 2, 3

Verdict: ACCEPTED

input
5000
5000 4999 4998 4997 4996 4995 ...

correct output
5000

user output
5000

Test 11

Group: 2, 3

Verdict:

input
5000
10 8 10 5 4 9 2 9 10 10 1 2 7 ...

correct output
9

user output
1

Test 12

Group: 2, 3

Verdict: ACCEPTED

input
5000
655923386 310000737 281882248 ...

correct output
28

user output
28

Test 13

Group: 2, 3

Verdict:

input
5000
123456789 123456790 123456791 ...

correct output
2706

user output
2528

Test 14

Group: 2, 3

Verdict: ACCEPTED

input
5000
123456789 123456790 123456791 ...

correct output
5000

user output
5000

Test 15

Group: 3

Verdict:

input
200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1

user output
(empty)

Test 16

Group: 3

Verdict:

input
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
200000

user output
(empty)

Test 17

Group: 3

Verdict:

input
200000
200000 199999 199998 199997 19...

correct output
200000

user output
(empty)

Test 18

Group: 3

Verdict:

input
200000
4 7 8 3 3 10 3 4 2 6 10 8 5 8 ...

correct output
10

user output
(empty)

Test 19

Group: 3

Verdict:

input
200000
824527039 112439661 517794857 ...

correct output
43

user output
(empty)

Test 20

Group: 3

Verdict:

input
200000
123456789 123456790 123456791 ...

correct output
30764

user output
(empty)

Test 21

Group: 3

Verdict:

input
200000
123456789 123456790 123456791 ...

correct output
61367

user output
(empty)

Test 22

Group: 1, 2, 3

Verdict: ACCEPTED

input
1
1

correct output
1

user output
1

Test 23

Group: 1, 2, 3

Verdict: ACCEPTED

input
2
1 1

correct output
1

user output
1

Test 24

Group: 1, 2, 3

Verdict: ACCEPTED

input
2
1 2

correct output
2

user output
2

Test 25

Group: 1, 2, 3

Verdict: ACCEPTED

input
2
2 1

correct output
2

user output
2

Test 26

Group: 1, 2, 3

Verdict: ACCEPTED

input
3
1 2 1

correct output
2

user output
2

Test 27

Group: 1, 2, 3

Verdict: ACCEPTED

input
3
1 2 3

correct output
3

user output
3

Test 28

Group: 1, 2, 3

Verdict: ACCEPTED

input
3
3 2 1

correct output
3

user output
3

Test 29

Group: 1, 2, 3

Verdict:

input
3
2 1 2

correct output
2

user output
1