Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Test Error?

Posted by zjsxzjb at 2008-10-30 20:12:12 on Problem 3658
我在usaco交了几遍都是AC的,到了这儿无论怎么都是wrong,我写了链表的和模拟链表的都wrong,可是usaco明明是对的,为什么?
{
LANG:PASCAL
PROG:alake
}
program alake;
const
  maxn=100001;
var
  h,w,pre,next:array[0..maxn] of longint;
  ans:array[1..maxn] of int64;
  n,i,m:longint;
  t:int64;
begin
  assign(input,'alake.in');reset(input);
  assign(output,'alake.out');rewrite(output);
  read(n);
  h[0]:=maxlongint;
  h[n+1]:=maxlongint;
  m:=1;
  for i:=1 to n do begin
    read(w[i],h[i]);
    pre[i]:=i-1;next[i]:=i+1;
    if h[i]<h[m] then m:=i;
  end;
  while h[m]<maxlongint do begin
    ans[m]:=t+w[m];
    next[pre[m]]:=next[m];
    pre[next[m]]:=pre[m];
    if h[pre[m]]<h[next[m]] then begin
	t:=t+trunc(w[m]*1.0*(h[pre[m]]-h[m]));
	inc(w[pre[m]],w[m]);
	m:=pre[m];
	while (m>0)and(h[pre[m]]<h[m]) do m:=pre[m];
    end else begin
	t:=t+trunc(w[m]*1.0*(h[next[m]]-h[m]));
	inc(w[next[m]],w[m]);
	m:=next[m];
	while (m>0)and(h[next[m]]<h[m]) do m:=next[m];
    end;
  end;
  for i:=1 to n do writeln(ans[i]);
  close(output);
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator