Codeforce Round #225 Div2 C
→ Practice?
Want to solve the contest problems after the official contest ends? Just register for practice and you will be able to submit solutions.
→ Last submissions
| Submission | Time | Verdict |
|---|---|---|
| 5753504 | 01/20/2014 08:27PM | Wrong answer on pretest 3 |
| 5753451 | 01/20/2014 08:26PM | Wrong answer on pretest 3 |
→ Problem tags
No tag edit access
1 #pragma comment(linker,"/STACK:102400000,102400000") 2 #include <cstdio> 3 #include <vector> 4 #include <cmath> 5 #include <queue> 6 #include <cstring> 7 #include <iostream> 8 #include <algorithm> 9 using namespace std; 10 #define INF 0x7fffffff 11 #define mod 1000000007 12 #define ll long long 13 #define maxn 200025 14 int n, m, k; 15 int a[maxn]; 16 int main(){ 17 scanf("%d", &n); 18 ll t = 0, x = 0; 19 for (int i = 0; i < n; i++){ 20 scanf("%d", &a[i]); 21 if (a[i] == 1)t++; 22 if (a[i] == 0)x += t; 23 } 24 ll ans = 10000000000000000; 25 ans = min(ans, x); 26 x = 0, t = 0; 27 for (int i = n - 1; i >= 0; i--){ 28 if (a[i] == 0)t++; 29 if (a[i] == 1)x += t; 30 } 31 ans = min(ans, x); 32 printf("%I64d\n", ans); 33 return 0; 34 }




浙公网安备 33010602011771号