Repository navigation
Expand file tree
/
Copy path1466B.cpp
More file actions
80 lines (69 loc) · 1.77 KB
/
Copy path1466B.cpp
File metadata and controls
80 lines (69 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
int main()
{
using namespace std;
int t;
cin >> t;
for(int i = 0; i < t; i++)
{
int len;
cin >> len;
int song[len];
int div = 0;
bool inc = false;
int incNo = 0;
for(int j = 0; j < len; j ++)
{
cin >> song[j];
if(song[j] > incNo)
inc = false;
if(j == 0)
div ++;
else if(song[j] > song[j - 1])
{
if(inc || incNo == song[j] - 1)
{
incNo = song[j];
song[j] ++;
}
else
inc = false;
div ++;
}
else if(song[j] == song[j-1])
{
if(!inc && incNo != song[j])
{
div ++;
incNo = song[j];
song[j] ++;
inc = true;
}
}
else
{
bool tempFlg = false;
for(int n = j - 2; n >= 0; n --)
{
if(song[j] == song[n])
{
tempFlg = true;
break;
}
else if(song[n] <= song[j]-2)
break;
}
if(!tempFlg)
div ++;
}
// cout << "div= " << div << endl;
// for(int w = 0; w <= j; w ++)
// cout << song[w] << " ";
// cout << endl;
}
cout << div << endl;
// for(int j = 0; j < len; j ++)
// cout << song[j] << " ";
// cout << endl;
}
}