1 solutions
-
0
#include<bits/stdc++.h> using namespace std; char a[1000000]; int b[1000000]; int main() { int n; cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; } int sum = 0, k = 0; /* 8 VVVTTXVV 3+1 -1 + 2 = 5 */ for(int i = 1; i <= n; i++){ if(a[i] == 'V'){ k++; sum++; } if(i == n || a[i+1] != 'V'){ if(k >= 3){ sum = sum + k-2; } k = 0; } if(a[i] == 'X'){ sum--; } } cout << sum; return 0; }
- 1
Information
- ID
- 1339
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 10
- Tags
- # Submissions
- 1
- Accepted
- 1
- Uploaded By