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 1581. Teamwork

AC
Posted by Dashka_Bu 10 Mar 2012 20:11
program idiots;
var n,i,h:integer;
a: array [1..1000] of integer;
begin
 readln(n);
 for i:=1 to n do
 read(a[i]);
 h:=1;
 for i:=1 to n do
  begin
   if a[i]=a[i+1] then h:=h+1;
   if a[i]<> a[i+1] then write(h,' ',a[i],' ');
   if a[i]<> a[i+1] then h:=1;
  end;
end.
Re: AC
Posted by kami_botanik 14 Mar 2013 20:05
but, I don't understood!
for i:=1 to n do
  begin
   if a[i]=a[i+1] then h:=h+1;
   if a[i]<> a[i+1] then write(h,' ',a[i],' ');
   if a[i]<> a[i+1] then h:=1;
  end;
You must get error in this stroke if a[i]=a[i+1] then h:=h+1; because your for loop is going untill n this must give Indexout of range exception isn't?
Re: AC
Posted by SeaEagle 30 Dec 2017 16:27
Nope, its neither c++ nor Java. It`s Pascal. Here you can do a lot of forbidden things without getting runtime error or Exception