Show all threads Hide all threads Show all messages Hide all messages | Solve by sorting. | Mahilewets | 1193. Queue at the Exam | 30 Jun 2017 00:40 | 1 | Sort by T1. Then set timer=0, ans =0. Then for all students in sorted order: if timer<T1 then timer=T1 timer=timer+T2 dtime=timer-T3 if dtime>ans then ans=dtime | Help me WA# 7 | Passarit | 1193. Queue at the Exam | 25 Sep 2014 20:32 | 5 | My algorithm is 1. sort wait time min -> max 2. variable time declared to add total time 3. add minimal wait time and exam time to var(time) 4. add exam time everybody 5. if time > freetime print time-freetime else print 0 I think my algorithm is right ,but I got WA #7 Could you help me plz? I see. My algorithm has a little mistake. Now I got AC. you're wrong ! Let consider this test : 2 100 50 160 200 250 300 your answer : 100 correct answer : 150 Phan Hoài Nam - Đại học Ngoại ngữ Tin Học TP.HCM - Your test case is wrong. T2 cant be greater than 240 Edited by author 25.09.2014 20:32 Edited by author 25.09.2014 20:33 Try test 2 50 10 50 150 20 200 Answer: 10 | Why WA#10? | evjava | 1193. Queue at the Exam | 29 Apr 2014 02:31 | 7 | program Project2; {$APPTYPE CONSOLE} uses SysUtils; type tt = record t1, t2, t3: integer; end; var i, n, time, tek: integer; a: array[1..50] of tt; begin readln(n); for i := 1 to n do readln(a[i].t1, a[i].t2, a[i].t3); { sort(1, n);} //....a[1].t1<a[2].t1<.....<a[n].t1 time := 0; tek := 0; for i := 1 to n do begin if tek >= a[i].t1 then tek := tek + a[i].t2 else tek := a[i].t1 + a[i].t2; if tek > a[i].t3 then begin time :=time+ tek - a[i].t3; tek := a[i].t3; end end; writeln(time); end. Why WA#10? [SESC USU] Zhirov Eugene 4 Dec 2009 22:04 I don't understand too. Have tried many test... And it works correctly. Help please by giving test =). Try this 3 100 10 120 70 40 150 99 15 100 The answer is 25. Edited by author 09.08.2011 01:40 Why? I think it 35: 0 min: 1:100 10 120 2:70 40 150 3:99 15 100 Q{} 70 min: 1:30 10 120 3:29 15 100 Q{2(40)} 70+29 min: 1:1 10 120 Q{2(11),3(15)} 70+29+1 min: Q(2(10),3(15),1(10)} fin:100+10+15+10 min; Third student doesn't fit into 35 minutes. So? Extra time for the second one is 0 for the third is 25 for the first it is - 15 Shift = 40. Why is it incorrect? Algorithm - sort by T1 - results 2,3,1 Total time for the second student to accomplish = 110 110 > 99 so, here goes the third ready student 110+15=125. 125 - 100 = 25 Total time = 125. 125 > 100 so, here goes the first ready student 125+10=135. 135 - 120= 15 So the total shift is 40 minutes. What's wrong? :/ Oh, that's true!!! Thanks!! | Problem is not clear. | balandini | 1193. Queue at the Exam | 1 Jun 2012 00:25 | 3 | What happens if 2 or more student are ready at one at the same time(they have equal T1)? Who will be first in queue? read statment carefully "All the numbers T1 are distinct." I made a mistake. It's all right with problem. | What problem it has? | daminus | 1193. Queue at the Exam | 1 Mar 2012 15:34 | 1 | var t1,t2,t3:array[0..50] of longint; procedure qsort(l,r:longint); var i,j,x,put:longint; begin i:=l;j:=r;x:=t1[(i+j) shr 1]; repeat while x>t1[i] do inc(i); while x<t1[j] do dec(j); if i<=j then begin put:=t1[i];t1[i]:=t1[j];t1[j]:=put; put:=t2[i];t2[i]:=t2[j];t2[j]:=put; put:=t3[i];t3[i]:=t3[j];t3[j]:=put; inc(i);dec(j); end; until i>j; if i<r then qsort(i,r); if j>l then qsort(l,j); end; var n,i,temp,need:longint; begin readln(n); for i:=1 to n do readln(t1[i],t2[i],t3[i]); qsort(1,n); for i:=1 to n do begin t1[i]:=t1[i]-temp; if t1[i]<0 then t1[i]:=0; temp:=temp+t1[i]+t2[i]; if t3[i]<temp then need:=need+(temp-t3[i]); end; writeln(need); end. Wrong Answer TEST 10. | WA #5 | Astekinane | 1193. Queue at the Exam | 23 Sep 2011 01:06 | 1 | WA #5 Astekinane 23 Sep 2011 01:06 Test my code, please. #include <iostream> #include <string> #include <vector> #include <queue> using namespace std; int N; bool proverka(vector <int> &used, queue <int> &Q){ if (!Q.empty()) return true; for (int i=0;i<N;i++) if (!used[i]) return true; return false; } int main(){ cin>>N; vector <int> T1(N); vector <int> T2(N); vector <int> T3(N); for (int i=0;i<N;i++) cin>>T1[i]>>T2[i]>>T3[i]; vector <int> used(N,0); queue <int> Q; int res=0; int tres=0; for (int m=0;m<4*N;m++){ int t=-1; for (int i=0;i<N;i++) if (!used[i] && (t==-1 || T1[i]<T1[t])) t=i;
//cout<<t+1<<": "<<T1[t]<<" "<<T2[t]<<" "<<T3[t]<<" "<<Q.front()<<endl; if (Q.empty() && t==-1) continue;
if (Q.empty()){ res+=T1[t]; used[t]=1; Q.push(t); for (int i=0;i<N;i++) if(!used[i]){ T1[i]-=T1[t]; if (T1[i]<=0){ Q.push(i); used[i]=1; } } continue; }
if (t==-1){ res+=T2[Q.front()]; tres=max(tres,(res-T3[Q.front()]<0 ? 0 : res-T3[Q.front()])); Q.pop(); continue; }
if (T1[t]<T2[Q.front()]){ res+=T1[t]; used[t]=1; Q.push(t); for (int i=0;i<N;i++) if(!used[i]){ T1[i]-=T1[t]; if (T1[i]<=0){ Q.push(i); used[1]=1; } } T2[Q.front()]-=T1[t]; if (T2[Q.front()]<=0) Q.pop(); continue; }
if (T1[t]>T2[Q.front()]){ res+=T2[Q.front()]; tres=max(tres,(res-T3[Q.front()]<0 ? 0 : res-T3[Q.front()])); for (int i=0;i<N;i++) if (!used[i]){ T1[i]-=T2[Q.front()]; if (T1[i]<=0){ Q.push(i); used[1]=1; } } Q.pop(); continue; }
}
cout<<tres<<endl; return 0; } | please try this test case if you get WA#10 | Ade | 1193. Queue at the Exam | 7 May 2011 18:20 | 1 | input: 3 100 100 100 101 100 100 102 100 100 out: 300 I forgot to update each T1 with the shift time and got WA#10. Interestingly, code with such big bug passes the 1~9 test case. | I don't understand problem 1193. Please help me! | raxtinhac | 1193. Queue at the Exam | 15 Aug 2010 14:01 | 13 | What change if shift beginning time of the exam to more early time ? Please explain to me. Thank! > What change if shift beginning time of the exam to more early > time ? Please explain to me. Thank! 70 + 40 = 110 // first student (70 40 150) 110 + 15 = 125 //second one (99 15 400) 125 + 10 = 135 // third one (100 10 120), he is 15 min late, (he's to be free at 120) i hope it helps. > > What change if shift beginning time of the exam to more early > > time ? Please explain to me. Thank! > > 70 + 40 = 110 // first student (70 40 150) > 110 + 15 = 125 //second one (99 15 400) > 125 + 10 = 135 // third one (100 10 120), > he is 15 min late, (he's to be free at 120) > > i hope it helps. > does this mean third should start at 110 and second start at 110+10=120? > > > What change if shift beginning time of the exam to more early > > > time ? Please explain to me. Thank! > > > > 70 + 40 = 110 // first student (70 40 150) > > 110 + 15 = 125 //second one (99 15 400) > > 125 + 10 = 135 // third one (100 10 120), > > he is 15 min late, (he's to be free at 120) > > > > i hope it helps. > > > does this mean third should start at 110 and second start at > 110+10=120? students should start the exam as fast as they are ready (by the order of T1) so second student cannot enter the room after third one ( i suppose ;) ) if the input is 4 100 10 120 70 40 150 99 15 400 101 50 160 what's to output and why Solution: 1st) #2 starting at 70 ending at 110 2nd) #3 starting at 110 ending at 125 3rd) #1 starting at 125 ending at 135 (a +15 shift) 4th) #4 starting at 135 ending at 185 (a +25 shift) That way the answer should be 25 > if the input is > 4 > 100 10 120 > 70 40 150 > 99 15 400 > 101 50 160 > what's to output and why > if the input is > 4 > 100 10 120 > 70 40 150 > 99 15 400 > 101 50 160 > what's to output and why let's see 70 + 40 = 110 (70 40 150) 110 + 15 = 125 (99 15 400) 125 + 10 = 135 (100 10 120) 15 min late 135 + 50 = 185 (101 50 160) 25 min late if examenator shifts the beginning of the exam by 25 minutes then every student will pass the exam before T3.
> if the input is > 4 > 100 10 120 > 70 40 150 > 99 15 400 > 101 50 160 > what's to output and why Thank you hajime, I got AC. 70 + 40 = 110 // first student (70 40 150) 110 + 10 = 120 //second one (100 10 120) 129 + 10 = 139 // third one (99 15 400), he is free at 139? wait =0; > 70 + 40 = 110 // first student (70 40 150) > 110 + 10 = 120 //second one (100 10 120) > 129 + 10 = 139 // third one (99 15 400), > he is free at 139? > wait =0; Oleg i think thirs student comes in queue before second as his t1 is 99 and thirds is 100 agree? Thank all the people above! | TO ADMINISTRATOR!WHAT IS #4 TEST?WHAT IS WRONG IN MY PROGRAM?PLEASE HELP ME | Kod | 1193. Queue at the Exam | 30 May 2010 15:44 | 1 | import java.util.Scanner; public class Queue { public static void main(String[] args) { Scanner input = new Scanner(System.in); koor A[] = new koor[50]; int i, j, st; int vaxt = 0; int temp, temp1, temp2; int max = 0; int N = input.nextInt(); for (i = 1; i <= N; i++) { A[i] = new koor(); A[i].T1 = input.nextInt(); A[i].T2 = input.nextInt(); A[i].T3 = input.nextInt(); } for (i = 1; i <= N - 1; i++) { for (j = 1; j <= N - 1; j++) { if (A[j].T1 > A[j + 1].T1) { temp = A[j].T1; A[j].T1 = A[j + 1].T1; A[j + 1].T1 = temp; temp1 = A[j].T2; A[j].T2 = A[j + 1].T2; A[j + 1].T2 = temp1; temp2 = A[j].T3; A[j].T3 = A[j + 1].T3; A[j + 1].T3 = temp2; } } }
st = A[1].T1 + A[1].T2; if (st > A[1].T3) { vaxt = st - A[1].T3; } for (i = 2; i <= N; i++) { if (st > A[i].T1) { st += A[i].T2; if (st > A[i].T3) { vaxt = st - A[i].T3; } } else { st = A[i].T1 + A[i].T2; if (st > A[i].T3) { vaxt = st - A[i].T3; } } if (vaxt > max) { max = vaxt; } } System.out.println(max); } } class koor { int T1; int T2; int T3; } Edited by author 30.05.2010 15:45 | What I must do?? | →MOPDOBOPOT← | 1193. Queue at the Exam | 15 Aug 2009 14:27 | 3 | I'm sorry, but WTF??? My program works correct on sample and all other tests, but I got WA1 >< Code: program abcdefgh; var t1,t2,t3: array[1..100] of longint; i,k,j,n,time: longint; begin read(n); for i:=1 to n do readln(t1[i],t2[i],t3[i]); for i:=1 to n-1 do for j:=i+1 to n do begin if t1[i]>t1[j] then begin k:=t1[i]; t1[i]:=t1[j]; t1[j]:=k; k:=t2[i]; t2[i]:=t2[j]; t2[j]:=k; end; if t3[i]>t3[j] then begin k:=t3[i]; t3[i]:=t3[j]; t3[j]:=k; end; end; time:=0; for i:=1 to n do if t1[i]<time then inc(time,t2[i]) else time:=t1[i]+t2[i]; if time-t3[1]<0 then writeln(0) else writeln(time-t3[1]); end. Edited by author 25.06.2009 16:17 Easy! You wrong here: > if time-t3[1]<0 then writeln(0) else writeln(time-t3[1]); This way to calculate time is wrong. Try this: 2 1 2 3 2 3 6 The answer is: 0 Your program output: 3 P.S. The first test is not necessary from statement, it may be more easier test, for exapmle. Edited by author 26.06.2009 02:28 Thanks, now I got AC :) Edited by author 15.08.2009 14:53 | Why WA5? Help!!! | tester | 1193. Queue at the Exam | 5 Aug 2009 15:01 | 1 | This is my program: #include <stdio.h> int main () { int n; int mas[100][3] = {}; bool maska[100] = {}; int solution = 0; int sum = 0; int min = 601, k = 0; scanf ("%d", &n); for (int i = 0; i < n; i++) { scanf ("%d%d%d", &mas[i][0], &mas[i][1], &mas[i][2]); if (mas[i][0] < min) { min = mas[i][0]; k = i; } } sum = mas[k][0]; maska[k] = 1; bool ok = false; int exit = 0; int save_i = 0; while (ok == false) { min = 9999999; sum += mas[k][1]; maska[k] = 1; ok = true; if (sum > mas[k][2]) solution += sum - mas[k][2]; bool key = false; exit = k; if (k == n - 1) k = -1; for (int i = k + 1; i < n; i++) { if (exit == i) break; if (maska[i] == 1) ok = true; if ((maska[i] == 0) && (mas[i][0] > sum) && (mas[i][0] < min)) { min = mas[i][0]; save_i = i; key = true; } if ((maska[i] == 0) && (mas[i][0] <= sum)) { k = i; ok = false; break; } if (i == n - 1) i = -1; } if ((ok == true) && (key == true)) { ok = false; k = save_i; sum = mas[k][0]; } } printf ("%d", solution); return 0; } | C# Crash test #8 | derxyz | 1193. Queue at the Exam | 17 Mar 2009 15:03 | 1 | Crash, because in Input numbers t1, t2, t3 separeted more then one space. So, I replaced string[] ss = Console.ReadLine().Split(' '); to string[] ss = Console.ReadLine().Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries); and got AC. | WA at Test #10 ! Are there any wrong in my program ? Please test my program with your program ! | Phan Hoài Nam - Đại học Ngoại ngữ Tin Học TP.HCM | 1193. Queue at the Exam | 13 Feb 2009 08:51 | 1 | I try many tests but not find out any mistake in my program ! Why ? Edited by author 13.02.2009 08:52 Edited by author 13.02.2009 08:52 | Help me please! I got WA # 9 | SanKeaR | 1193. Queue at the Exam | 29 Aug 2008 00:31 | 2 | This is my code: var n,i,j,max,k:integer; t1,t2,t3:array[1..101] of integer; begin read(n); k:=0; for i:=1 to n do read(t1[i],t2[i],t3[i]); for i:=1 to n do for j:=n downto i+1 do if t1[i]>t1[j] then begin k:=t1[i]; t1[i]:=t1[j]; t1[j]:=k; k:=t2[i]; t2[i]:=t2[j]; t2[j]:=k; k:=t3[i]; t3[i]:=t3[j]; t3[j]:=k; end; k:=t1[1]; max:=0; j:=0; for i:=1 to n do begin inc(k,t2[i]); if k>t3[i] then j:=k-t3[i]; if j>max then max:=j; end; write(max); end. Sorry for Russian... Помогите мне пожалуйста, буду очень благодарен!!! Edited by author 28.08.2008 23:40 You code is wrong! use queue and got AC! ;) | SO help me!! i tried to understand but still WA! :P | Locomotive | 1193. Queue at the Exam | 26 Mar 2008 23:04 | 3 | Var a :array[0..100,1..3] of integer; i,j,n :byte; now,ans :integer; begin readln(n); for i:=1 to n do readln(a[i,1],a[i,2],a[i,3]); for i:=1 to n-1 do for j:=i+1 to n do if a[i,1]>a[j,1] then begin a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0]; end; ans:=0; now:=a[1,1]; for i:=1 to n do begin now:=now+a[i,2]; if now-a[i,3]>ans then ans:=now-a[i,3]; end; writeln(ans); end. What is goin` wrong??? > Var > a :array[0..100,1..3] of integer; > i,j,n :byte; > now,ans :integer; > begin > readln(n); > for i:=1 to n do readln(a[i,1],a[i,2],a[i,3]); > for i:=1 to n-1 do > for j:=i+1 to n do > if a[i,1]>a[j,1] then begin > a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0]; end; > ans:=0; now:=a[1,1]; > for i:=1 to n do begin > now:=now+a[i,2]; > if now-a[i,3]>ans then ans:=now-a[i,3]; > end; > writeln(ans); > end. > > > What is goin` wrong??? ~~~~~~~~~ i forgot : if now<a[i,1] then now:=a[i,1] !!!! | Why WA9? Help!!! | tn | 1193. Queue at the Exam | 23 Mar 2008 23:45 | 2 | Please, give me this test... | WA #10 It's urgent that you help me | basted | 1193. Queue at the Exam | 29 Jan 2008 00:20 | 1 | What's wrong? #include <stdio.h> #include <stdlib.h> int n,x,s; typedef struct{ int t1,t2,t3; }st; st t[110]; int max(int a,int b){ if(a>b)return a; else return b; } int cmp(const void *a,const void *b){ const st *c=(st *)a, *d=(st *)b; return c->t1 - d->t1; } int main(){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d %d %d",&t[i].t1,&t[i].t2,&t[i].t3); } qsort(t,n,sizeof(st),cmp); for(int i=0;i<n;i++){ t[i].t1=max(t[i].t1,x); x=t[i].t1 + t[i].t2; s+=max(0,x-t[i].t3); } printf("%d\n",s); return 0; } | Any hints WA #8? | Alexey Procenko | 1193. Queue at the Exam | 7 Dec 2007 02:29 | 2 | I am still getting WA#8. Please, give ne some hints or tests. I have got AC! My mistake was the length of array. I changed it to 101 element and got AC | I don't quite understand the meaning!please help! | Ural_Happy New Year! | 1193. Queue at the Exam | 21 Aug 2007 14:01 | 2 | If the input is 4 100 10 120 70 40 150 99 15 400 400 50 160 what's the output and why? this is my code: -------------------------- program t1193; type types=record b:longint; l:longint; e:longint; end; var n,i,start:longint; t:array[0..100]of types; procedure qsort(l,r:integer); var j,i,x,y:integer; begin i:=l;j:=r; x:=t[(l+r) div 2].b; repeat while t[i].b<x do inc(i); while t[j].b>x do dec(j); if i<=j then begin y:=t[i].b; t[i].b:=t[j].b; t[j].b:=y; y:=t[i].e; t[i].e:=t[j].e; t[j].e:=y; y:=t[i].l; t[i].l:=t[j].l; t[j].l:=y; inc(i);dec(j); end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r); end; begin readln(n); for i:=1 to n do readln(t[i].b,t[i].l,t[i].e); qsort(1,n); start:=t[1].b; for i:=1 to n do begin start:=start+t[i].l; if t[i+1].b>start then start:=t[i+1].b; end; start:=start-t[n].e; if start>0 then writeln(start) else writeln('0'); end. In the problem write T1<=T3 and you write "400 50 160" it is wrong. sorry my english is very bad | Can you give me some tests? Please... | DixonD (Lviv NU) | 1193. Queue at the Exam | 11 Mar 2007 18:55 | 1 | |
|
|