### Saratov State University :: Online Contester

::Go
- home
- news
- register
 - update personal info
 - problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- projects

 ::Poll Are you registered on Codeforces?YesNoWhat is it???[results]

::webboard

 Why still WA on test 2 as i Check this?!
Author: sina37
ID: 062999
Problem: 239
Contest: 0
Date: 2015-03-24 21:27:14

so why this code is incorrect ? i check it for test #2 but i see WA on test 2 ! should I use scanf ? ? ? ?

// Tursday 24th MARCH 239 sgu
#include <iostream>
using namespace std;

int ans;

int main() {
int c[1000 + 12] = {} , a[1000 + 12] = {}, n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
c[i] = a[i];
}

if (n == 1) {
if (a[0] <= 1)
cout << 1 << endl;
else
cout << 0 << endl;
return 0;
}
if (a[0] >= 1) {
a[0]--;
a[1]--;
}
for (int i = 1; i < n ; i++) {
if (a[i - 1]) {
a[i - 1]--;
a[i]--;
if (i + 1 < n)
a[i + 1]--;
}
}
bool talent = true;
for (int i = 0; i < n; i++) {
if (a[i] != 0)
talent = false;
}

if (talent)
ans++;

for (int i = 1; i < n; i++) {
if (c[i - 1]) {
c[i - 1]--;
c[i]--;
if (i + 1 < n)
c[i + 1]--;
}
}
talent = true;
for (int i = 0; i < n; i++) {
if (c[i - 1] != 0) {
talent = false;
}
}
if (talent)
ans++;
cout << ans << endl;
return 0;
}