Saratov State University :: Online Contester


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

::Poll
Are you registered on Codeforces?
Yes
No
What 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;
}

see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-09-21 12:44:35Online Contester Team © 2002 - 2016. All rights reserved.