|
|
вернуться в форумMy problem gets WA but I have no idea why. Could anyone help me? My e-mail: drozdz84@wp.pl #include <iostream.h> long *arr; int n; void load() { int i; int l; char c; cin >> n; arr = new long[n]; for (i=0; i<n; i++) { while (cin.get(c) && c!=' '); cin >> l; if (l==1) cin >> arr[i]; else arr[i]=0; } } void check() { long l=0, i; int cheat=0; for (i=n-1; i>=0 && !cheat; i--) { if (arr[i]) { if (l>arr[i]) cheat=1; l=arr[i]+1; } else arr[i]=l++; } if (!cheat) { l=0; for (i=0; i<n; i++) l+=arr[i]; if (l>10000) cheat=1; } if (!cheat) cout << "YES"; else cout << "NO"; } int main() { load(); check(); return 0; } Re: My problem gets WA but I have no idea why. Could anyone help me? |
|
|