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 1193. Queue at the Exam

Why WA need help
Posted by Hemisphere 30 Jul 2006 01:54
#include <stdio.h>

int main()
{
 struct student {
 long t1;
 long t2;
 long t3;
 };

 student stu[100];
 long max=0,stm=0;
 int i,j,n,tmp;

 scanf("%d",&n);

 for(i=0;i<n;i++) { stu[i].t1=0;stu[i].t2=0;stu[i].t3=0; }
 for(i=0;i<n;i++) scanf("%d %d %d",&stu[i].t1,&stu[i].t2,&stu[i].t3);

  for (i=0; i<n; i++) {
  for (j=0; j<n-1; j++)
    if (stu[j+1].t1 < stu[j].t1) {
      tmp = stu[j].t1;
      stu[j].t1 = stu[j+1].t1;
      stu[j+1].t1 = tmp;

      tmp = stu[j].t2;
      stu[j].t2 = stu[j+1].t2;
      stu[j+1].t2 = tmp;

      tmp = stu[j].t3;
      stu[j].t3 = stu[j+1].t3;
      stu[j+1].t3 = tmp;
  }
 }

 stm=stu[0].t1;

 for(i=0;i<n;i++) {
    stm=stm+stu[i].t2;
    j=stm-stu[i].t3;
    if(j>max)max=j;
 }

 printf("%d",max);

 return 0;
}