#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;
int dp[1004];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, q;
cin >> n >> m >> q;
vector<int> a(n);
int ans = 0;
for(int i = 0; i < n; ++i){
cin >> a[i];
if(i && a[i] == a[i - 1]){
ans += a[i];
}
}
vector<int> chk(3);
for(int i = 0; i < n; ++i){
if(a[i] > 0){
if(i && !chk[a[i]]) ++ans;
chk[a[i]] = 1;
int j = i;
while(j + 1 < n && a[i] == a[j + 1]){
++j;
}
i = j;
if(i + 1 < n){
chk[a[i]] = 1;
++ans;
}
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
8 ms |
1876 KB |
Output is correct |
3 |
Correct |
9 ms |
1876 KB |
Output is correct |
4 |
Incorrect |
10 ms |
1876 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
8 ms |
1876 KB |
Output is correct |
3 |
Correct |
9 ms |
1876 KB |
Output is correct |
4 |
Incorrect |
10 ms |
1876 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
8 ms |
1876 KB |
Output is correct |
3 |
Correct |
9 ms |
1876 KB |
Output is correct |
4 |
Incorrect |
10 ms |
1876 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
8 ms |
1876 KB |
Output is correct |
3 |
Correct |
9 ms |
1876 KB |
Output is correct |
4 |
Incorrect |
10 ms |
1876 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
8 ms |
1876 KB |
Output is correct |
3 |
Correct |
9 ms |
1876 KB |
Output is correct |
4 |
Incorrect |
10 ms |
1876 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |