ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1190. Bar of Chocolate

My problem gets WA but I have no idea why. Could anyone help me?
Posted by Krzysztof "Doodge" Drozdz 28 Jun 2002 21:30
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?
Posted by Terrific 29 Jun 2002 10:37
It's recommended that you discuss problems at
http://www.ioiforum.org/en/
A lot of excellent students (e.g.
http://acm.timus.ru/author.asp?id=12163 )
are from the forum.

You can register a username at
http://www.ioiforum.org/en/userreg.asp

Try to discuss problems there, you will have fun of solving probelms!