10258 - Contest Scoreboard

All about problems in Volume 102. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Why wrong answer...???Plz help.......

Post by brianfry713 » Thu Jul 24, 2014 10:42 pm

Input:

Code: Select all

3

78 7 1 U
75 1 7 C
93 8 7 U
25 5 11 R
94 9 14 I
11 4 21 E
54 9 29 E
78 3 36 R
68 8 37 R
40 9 44 R
82 2 51 I
87 7 51 R
41 8 52 U
94 5 56 E
79 3 57 I
37 4 62 I
35 6 67 U
85 8 74 R
76 9 79 C
43 2 88 I
4 3 95 R
61 2 104 C
14 9 112 R
57 1 112 I
89 1 113 C
60 3 117 I
73 6 120 E
52 8 122 U
61 7 123 I
77 2 129 U
14 1 129 R
23 6 138 E
57 4 139 U
53 7 148 I
90 4 153 R
45 1 154 E
85 3 159 U
55 5 160 U
52 8 160 R
49 1 166 U
84 1 169 R
53 1 174 I
26 4 178 R
3 5 184 E
35 9 186 R
48 2 191 U
100 6 192 R
51 6 199 R
44 1 205 C
2 6 212 I
91 4 215 I
6 7 218 E
34 9 226 R
34 9 226 I
90 7 226 C
83 8 230 E
20 9 232 R
33 6 240 C
33 5 249 R
82 4 252 C
85 7 256 U
8 3 262 U
51 9 266 R
84 2 267 C
69 5 275 U
89 9 284 U
34 7 284 U
53 2 292 I
64 4 296 C
18 4 297 I
62 3 305 C
34 9 308 C
91 5 317 I
63 4 319 E
34 1 321 R
63 3 326 E
79 7 331 I
8 4 340 R
33 5 347 R
27 7 352 I
4 8 361 R
6 6 364 I
16 3 364 I
28 5 364 U
97 9 370 R
72 4 371 C
83 8 376 E
65 3 378 E
62 3 384 I
75 1 386 C
85 3 389 E
44 3 396 E
24 1 397 E
89 7 398 R
67 9 399 E
7 4 407 C
81 4 413 E
91 9 418 I
85 8 423 I
89 4 428 C
85 5 429 E
90 7 435 E
78 6 444 C
33 5 450 R
75 5 457 U
85 3 466 E
31 9 471 I
45 8 472 U
38 4 481 R
4 8 485 I
28 3 494 E
63 4 497 I
10 9 497 E
12 9 503 U
30 3 509 I
86 7 515 C
44 4 524 I
5 1 529 U
63 5 538 E
68 3 543 R
16 3 552 U
15 1 560 R
13 4 563 R
90 4 572 U
78 3 574 E
69 7 581 U
10 6 583 I
30 2 591 R
92 8 594 U
79 3 599 C
90 3 606 U
97 1 610 C
46 9 616 E
12 3 623 U
37 1 629 U
77 8 632 C
94 4 640 R
38 3 647 R
58 4 650 E
75 6 656 I
73 1 658 C
67 9 658 R
83 5 665 E
63 4 669 U
21 8 672 U
91 3 679 E
4 4 684 C
67 3 687 E
27 3 693 U
60 7 695 U
85 7 703 E
3 4 710 R
39 1 710 I
35 7 717 R
64 3 717 C
24 4 723 I
99 7 729 I
76 7 736 U
17 2 743 E
40 8 749 C
7 9 756 E
47 2 762 E
79 4 763 C
16 2 772 C
17 4 781 I
54 2 785 I
37 2 785 E
35 2 792 I
62 6 797 I
60 5 803 U
14 1 807 E
89 4 816 R
6 4 817 E
51 8 817 R
72 8 821 I
10 3 823 I
42 4 826 R
48 5 829 R
79 2 835 U
34 9 837 C
10 6 844 U
77 1 846 R
10 7 851 I
41 9 858 E
38 6 862 C
32 7 865 E
57 4 867 U
28 2 875 U
26 7 878 I
71 7 883 E
70 9 883 I
61 7 889 E
65 7 898 C
54 7 907 C
74 7 910 E
45 1 919 C
69 6 922 U
40 6 931 E
84 9 936 I
64 8 938 C
96 7 944 E
15 8 953 U
80 9 962 I
97 5 963 I
19 8 972 C
100 9 973 U
54 4 982 E
59 9 982 U

25 2 7 C
18 9 13 C
100 6 21 C
19 5 21 U
3 7 25 C
32 6 26 U
4 8 29 I
100 9 32 I
98 3 40 U
15 5 46 R
60 6 55 R
21 5 60 U
63 5 69 E
33 1 76 U
50 2 80 I
41 3 89 C
7 8 89 R
11 6 98 I
27 6 106 E
41 7 115 I
80 2 115 C
76 4 115 I
67 6 120 E
16 7 124 C
26 1 128 U
98 2 135 I
78 7 142 R
81 1 142 I
75 4 146 R
87 1 155 C
92 3 160 U
11 4 165 E
2 1 169 R
69 4 169 U
93 4 171 E
91 1 177 I
9 3 186 C
39 7 187 I
100 9 191 U
65 2 200 C
7 6 204 R
5 5 206 I
40 8 207 U
30 7 207 C
71 9 214 U
8 8 215 C
96 2 220 R
11 8 224 U
90 4 231 U
41 6 238 U
57 3 244 I
74 9 247 U
66 3 250 E
48 5 251 I
85 3 251 I
22 4 253 C
83 6 258 R
73 7 263 U
68 5 265 U
68 7 268 I
55 7 270 I
43 7 272 U
45 3 274 C
38 8 276 I
97 9 284 C
44 7 293 I
66 7 293 C
12 2 301 I
32 7 308 U
22 6 315 U
18 1 318 C
22 3 319 E
57 9 324 I
26 1 329 E
9 8 329 E
52 2 331 C
25 4 336 I
72 2 342 E
98 9 348 R
65 9 355 C
99 7 356 U
21 4 364 I
46 3 366 U
41 6 369 C
48 2 377 U
62 1 381 C
71 9 384 R
76 2 386 I
1 5 386 I
62 4 395 E
13 4 402 C
42 5 404 R
37 3 406 U
54 3 414 U
20 6 419 C
64 6 420 E
97 8 427 U
43 2 429 C
89 3 435 U
70 6 442 E
11 4 451 E
98 5 451 R
14 2 460 E
21 8 460 E
12 4 467 R
64 1 474 I
27 7 481 R
6 9 484 C
88 4 489 I
86 2 494 C
75 3 495 I
7 1 502 I
51 6 502 R
89 6 503 C
64 1 512 E
63 1 517 R
35 7 525 C
92 9 532 U
57 1 539 I
23 4 548 I
15 9 551 C
53 4 551 E
67 2 552 I
5 3 555 R
92 4 557 I
54 7 563 U
86 6 567 E
37 4 567 C
75 4 569 I
33 9 570 R
14 2 578 U
55 9 578 C
78 2 579 E
59 3 581 C
95 2 583 C
85 2 585 I
57 3 588 U
21 2 588 C
12 9 588 C
84 4 588 U
88 4 590 C
81 3 598 C
15 4 600 I
29 1 603 C
81 5 603 E
77 1 609 I
39 2 615 C
4 3 623 R
21 3 625 C
26 2 628 R
75 7 629 R
75 9 633 R
98 9 634 C
85 7 640 U
85 6 645 C
48 3 647 R
18 2 649 I
2 9 649 R
36 1 650 R
82 9 659 I
42 9 662 E
25 9 671 I
97 5 675 I
32 8 683 E
54 9 685 U
39 6 692 U
13 2 692 E
92 8 699 U
39 9 706 C
59 3 710 R
13 7 713 C
60 8 719 C
5 5 724 C
22 1 733 C
25 4 739 R
15 2 744 U
91 9 750 I
32 9 755 I
21 5 758 I
26 4 766 R
29 3 773 C
75 1 780 I
48 1 780 C
73 6 786 R
87 6 786 R
30 9 792 E
34 5 794 I
96 6 802 R
98 8 809 U
55 9 810 U
32 7 813 I
59 3 821 C
21 5 825 E
9 1 830 R
92 3 833 I
64 8 837 I
4 8 846 C
59 2 849 U
47 4 855 C
63 4 862 C
51 2 867 U
5 5 868 E
73 5 876 I
95 9 879 R
100 6 883 U
41 7 886 U
47 1 895 I
65 9 902 C
73 5 911 C
20 1 912 R
36 2 912 U
22 1 917 I
15 5 918 I
12 5 918 C
31 6 919 C
94 2 921 C
49 7 928 U
75 6 930 I
43 4 934 U
78 7 940 E
18 8 945 I
100 4 951 R
93 3 960 C
30 8 960 I
84 3 961 U
76 1 970 R
60 4 973 C
92 1 977 C
40 4 980 U
88 8 987 E
44 2 988 R
43 6 997 E
69 2 1006 R
65 3 1007 I
73 4 1013 R
28 7 1017 C
38 7 1017 E
98 3 1023 E
83 7 1024 C
92 1 1026 U
20 9 1033 C
100 4 1034 C
85 6 1043 I
31 5 1051 E
78 8 1052 R
77 1 1055 I
29 2 1059 R
1 1 1060 U
35 3 1063 C
78 9 1068 C
100 8 1076 I
54 3 1078 E
2 6 1086 I
55 6 1094 R
58 8 1098 E
21 8 1105 C
89 5 1106 E
56 4 1110 I
94 3 1119 U
14 3 1124 C
88 2 1131 E
64 7 1137 C
64 3 1141 R
26 2 1143 C
97 2 1143 I
84 4 1147 U
70 8 1151 R
83 3 1154 C
44 4 1159 E
81 1 1165 R
74 1 1174 E
22 1 1183 C
56 4 1184 R
15 5 1184 I
25 2 1193 R

72 4 1 U
42 6 8 C
33 4 11 C
77 2 17 C
76 9 23 R
8 5 28 C
66 8 34 R
1 9 42 E
52 9 44 E
60 9 50 E
87 1 50 E
41 4 51 C
44 2 58 R
17 7 66 U
17 2 72 R
79 4 78 C
58 1 79 R
70 4 88 U
81 3 97 U
61 9 100 I
55 9 104 I
18 8 113 R
8 6 114 U
100 2 119 I
71 9 120 I
91 1 121 R
46 2 123 U
56 8 132 U
12 5 141 C
77 3 146 I
83 3 152 I
61 3 159 I
84 9 159 I
62 1 168 U
96 3 171 C
21 2 171 R
10 7 175 R
83 7 180 U
50 6 189 R
88 8 194 E
62 7 194 E
46 1 203 C
83 6 205 R
38 7 206 R
51 3 210 R
83 8 213 C
55 2 220 R
44 9 221 C
11 8 230 U
53 1 230 C
18 6 234 R
97 4 236 I
84 8 236 U
98 6 244 E
40 2 250 E
88 8 256 E
70 2 265 C
87 7 267 C
48 6 272 E
32 1 272 E
54 7 275 E
68 2 275 R
81 7 279 C
61 2 280 I
6 3 283 I
81 3 286 E
15 9 289 I
24 7 297 U
50 9 306 U
31 1 312 E
88 8 316 R
55 3 316 U
21 8 322 C
1 6 326 C
62 9 327 C
25 4 332 U
75 3 338 U
80 5 340 I
46 7 343 C
43 1 348 U
86 2 356 I
20 1 362 E
50 3 366 I
45 5 372 R
28 5 374 U
75 6 383 U
37 2 383 I
94 9 387 I
1 3 389 R
6 3 397 C
37 8 405 E
57 4 409 R
37 4 414 I
70 3 421 U
65 5 421 I
35 1 423 R
91 3 432 E
77 2 438 U
89 6 440 I
21 9 443 R
28 4 451 R
97 6 457 U
53 7 457 E
74 6 459 R
21 2 462 C
51 8 467 C
98 7 469 U
59 5 469 C
47 5 477 U
50 4 484 C
32 8 493 E
43 6 501 R
58 6 501 C
96 9 502 R
86 5 507 U
54 2 512 E
43 4 515 E
11 5 524 U
29 2 524 I
12 6 525 E
3 9 534 E
23 4 541 U
12 6 547 R
50 7 553 I
64 8 555 U
15 2 559 E
25 3 560 R
39 2 566 C
97 5 575 R
14 3 580 U
37 1 580 I
34 5 589 I
81 5 593 E
100 9 599 E
56 2 606 E
4 2 610 C
6 8 619 E
57 8 623 U
46 6 629 E
13 6 634 R
81 2 638 E
85 8 643 E
35 8 651 E
AC output:

Code: Select all

64 3 1951
89 2 541
79 2 1382
75 1 7
76 1 79
61 1 104
44 1 205
90 1 226
33 1 240
82 1 252
84 1 267
62 1 305
34 1 328
72 1 371
7 1 407
78 1 444
86 1 515
97 1 610
77 1 632
73 1 658
4 1 684
40 1 749
16 1 772
38 1 862
65 1 898
54 1 907
45 1 919
19 1 972
2 0 0
3 0 0
5 0 0
6 0 0
8 0 0
10 0 0
11 0 0
12 0 0
13 0 0
14 0 0
15 0 0
17 0 0
18 0 0
20 0 0
21 0 0
23 0 0
24 0 0
25 0 0
26 0 0
27 0 0
28 0 0
30 0 0
31 0 0
32 0 0
35 0 0
37 0 0
39 0 0
41 0 0
42 0 0
43 0 0
46 0 0
47 0 0
48 0 0
49 0 0
51 0 0
52 0 0
53 0 0
55 0 0
57 0 0
58 0 0
59 0 0
60 0 0
63 0 0
67 0 0
68 0 0
69 0 0
70 0 0
71 0 0
74 0 0
80 0 0
81 0 0
83 0 0
85 0 0
87 0 0
91 0 0
92 0 0
93 0 0
94 0 0
96 0 0
99 0 0
100 0 0

21 3 2318
18 2 331
41 2 458
65 2 555
22 2 986
100 2 1055
13 2 1115
39 2 1321
29 2 1376
20 2 1452
12 2 1506
35 2 1588
60 2 1692
83 2 2178
25 1 7
3 1 25
80 1 115
16 1 124
87 1 155
9 1 186
30 1 207
8 1 215
45 1 274
97 1 284
66 1 293
52 1 331
62 1 381
43 1 429
6 1 484
86 1 494
89 1 503
15 1 551
37 1 567
55 1 578
59 1 581
95 1 583
81 1 598
88 1 610
98 1 634
85 1 645
5 1 744
48 1 780
47 1 855
63 1 862
4 1 866
31 1 919
94 1 921
73 1 931
93 1 960
92 1 977
28 1 1017
78 1 1068
14 1 1124
64 1 1137
26 1 1143
1 0 0
2 0 0
7 0 0
11 0 0
19 0 0
23 0 0
27 0 0
32 0 0
33 0 0
34 0 0
36 0 0
38 0 0
40 0 0
42 0 0
44 0 0
46 0 0
49 0 0
50 0 0
51 0 0
53 0 0
54 0 0
56 0 0
57 0 0
58 0 0
67 0 0
68 0 0
69 0 0
70 0 0
71 0 0
72 0 0
74 0 0
75 0 0
76 0 0
77 0 0
82 0 0
84 0 0
90 0 0
91 0 0
96 0 0
99 0 0

46 2 546
21 2 784
42 1 8
33 1 11
77 1 17
8 1 28
41 1 51
79 1 78
12 1 141
96 1 171
83 1 213
44 1 221
53 1 230
70 1 265
87 1 267
81 1 279
1 1 326
62 1 327
6 1 417
51 1 467
59 1 469
50 1 484
58 1 501
39 1 566
4 1 610
3 0 0
10 0 0
11 0 0
13 0 0
14 0 0
15 0 0
17 0 0
18 0 0
20 0 0
23 0 0
24 0 0
25 0 0
28 0 0
29 0 0
31 0 0
32 0 0
34 0 0
35 0 0
37 0 0
38 0 0
40 0 0
43 0 0
45 0 0
47 0 0
48 0 0
52 0 0
54 0 0
55 0 0
56 0 0
57 0 0
60 0 0
61 0 0
64 0 0
65 0 0
66 0 0
68 0 0
71 0 0
72 0 0
74 0 0
75 0 0
76 0 0
80 0 0
84 0 0
85 0 0
86 0 0
88 0 0
89 0 0
91 0 0
94 0 0
97 0 0
98 0 0
100 0 0
Check input and AC output for thousands of problems on uDebug!

Rayhan_ICT
New poster
Posts: 3
Joined: Wed Jul 23, 2014 1:08 pm

Re: Why wrong answer...???Plz help.......

Post by Rayhan_ICT » Fri Jul 25, 2014 1:16 pm

thanks a lot...... :P

Robert_Alonso
New poster
Posts: 8
Joined: Fri Jul 25, 2014 2:04 am

Re: 10258 - Contest Scoreboard

Post by Robert_Alonso » Thu Aug 07, 2014 4:51 am

Hi, I've read all the posts and tried all the test cases, but still getting WA. I also have considered the blank line after the last test case. Please help :(

Code: Select all

Removed after AC.
Last edited by Robert_Alonso on Thu Aug 07, 2014 6:40 am, edited 1 time in total.

lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 10258 - Contest Scoreboard

Post by lbv » Thu Aug 07, 2014 5:23 am

Robert_Alonso wrote:Hi, I've read all the posts and tried all the test cases, but still getting WA. I also have considered the blank line after the last test case. Please help :(
Try:

Input

Code: Select all

3

1 1 4 R
1 1 10 I
2 1 127 C
5 1 145 C
4 1 225 U
1 1 237 C
5 1 280 C
1 1 285 I
3 1 286 C
2 1 292 C
1 1 293 C
3 1 297 C

4 1 16 C
4 1 71 I
5 1 105 C
3 1 112 I
5 1 123 I
3 1 245 R
2 1 266 C
4 1 282 E
4 1 294 C

1 3 14 I
2 3 24 I
2 3 52 U
3 3 72 I
1 2 85 I
3 1 162 C
2 3 206 R
3 1 207 I
1 2 226 I
3 1 281 C
2 1 297 C
Output

Code: Select all

2 1 127
5 1 145
1 1 257
3 1 286
4 0 0

4 1 16
5 1 105
2 1 266
3 0 0

3 1 162
2 1 297
1 0 0
Also notice that the output specification states: The outputs of two consecutive cases will be separated by a blank line., but it does not say that there should be a blank line after the last case.

Robert_Alonso
New poster
Posts: 8
Joined: Fri Jul 25, 2014 2:04 am

Re: 10258 - Contest Scoreboard

Post by Robert_Alonso » Thu Aug 07, 2014 6:40 am

Thank you very much lbv! Finally got AC. :)

dav
New poster
Posts: 1
Joined: Sat Aug 23, 2014 9:40 pm

Re: 10258 - Contest Scoreboard

Post by dav » Sat Aug 23, 2014 9:46 pm

Hi guys, I would be grateful if you could help me.
Verdict: WA
I've tried many of the cases offered in this thread and have achieved correct output.

My code is:

Code: Select all

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;


class Main {
	
	public class probStat {
		public Integer timeSpent;
		public Boolean solved;
		public probStat(){
			this.timeSpent = 0;
			this.solved = false;
		}
	}
	
	public class Contestant {
		public Integer problemsSolved;
		public Integer penaltyTime;
		public Boolean attemptedCompetition;
		public probStat[] problems;
		
		public Contestant(){
			this.problemsSolved = 0;
			this.penaltyTime= 0;
			attemptedCompetition = false;
			this.problems = new probStat[10];//use only idx 1 ~ 9
			for (int i = 0; i< 10; i++){
				this.problems[i] = new probStat();
			}
		}
		
	}
	
	public class ContestantLessMem{
		public Integer iD;
		public Integer problemsSolved;
		public Integer penaltyTime;
		
		public ContestantLessMem(Integer iD, Integer pS, Integer pT){
			this.iD = iD;
			problemsSolved = pS;
			penaltyTime = pT;
		}
	}
	
	Comparator <ContestantLessMem> cmpPT= new Comparator <ContestantLessMem>() {
		public int compare(ContestantLessMem lft, ContestantLessMem rgt) {
			return lft.penaltyTime.compareTo(rgt.penaltyTime);
		}
	};
	
	Comparator <ContestantLessMem> cmpPS= new Comparator <ContestantLessMem>() {
		public int compare(ContestantLessMem lft, ContestantLessMem rgt) {
			return rgt.problemsSolved.compareTo(lft.problemsSolved);
		}
	};


	
	
	public static void main(String[] args){
		
		Main m = new Main();
		m.begin();
	}



	public void begin () {

//		
//		
//		File f = new File("C:\\Users\\Time\\Desktop\\jws\\UVa_10258_ContestScoreboard\\src\\i.txt");
//		
//		Scanner scanner = new Scanner(new FileInputStream(f));
		Scanner scanner = new Scanner(System.in);

		Integer numberTestCases = Integer.parseInt(scanner.nextLine());
		

		scanner.nextLine(); //discard newline
		
		for(int iCases = 0; iCases < numberTestCases; iCases ++) {
			
			Contestant[] cArr = new Contestant[101]; //use only idx 1 ~ 100
			
			for(int i = 0; i < 101; i++){
				cArr[i] = new Contestant();
			}
			
			String elemJudgeQ = scanner.nextLine();
			
			while ( ! (elemJudgeQ.isEmpty() ) ) {
				
				// Extract info from a single row's input
				String[] elemParts = elemJudgeQ.split("\\s+");
				Integer iD = Integer.parseInt(elemParts[0]);
				Integer probID = Integer.parseInt(elemParts[1]);
				Integer timeSpent = Integer.parseInt(elemParts[2]);
				String subType = elemParts[3];
				
				// Insert info
				if(subType.equalsIgnoreCase("I")){
					
					if(cArr[iD].problems[probID].solved == false ) {
						cArr[iD].problems[probID].timeSpent += 20;
					}
				} else if (subType.equalsIgnoreCase("C")){

					if(cArr[iD].problems[probID].solved == false ) {

						cArr[iD].problems[probID].timeSpent += timeSpent;
						cArr[iD].problems[probID].solved = true;
						cArr[iD].problemsSolved++;
						cArr[iD].penaltyTime += cArr[iD].problems[probID].timeSpent;
					}else {
						; //ignore
					}

				} else {
					; //don't care
				}

				//mark contestant as attempted compeition
				cArr[iD].attemptedCompetition = true;

				
				
				if(scanner.hasNextLine()) {
					elemJudgeQ = scanner.nextLine();
				}else {
					elemJudgeQ = "";
				}
			}
			
			
			
			// ONly incl. the people who matter
			
			ArrayList<ContestantLessMem> vArr = new ArrayList<ContestantLessMem>();
			
			for(Integer iPplID = 1; iPplID<100; iPplID++){
				if (cArr[iPplID].attemptedCompetition) {
					ContestantLessMem cLM = new ContestantLessMem(iPplID, cArr[iPplID].problemsSolved, cArr[iPplID].penaltyTime);
					vArr.add(cLM);
				}
					
			}
			
			//sort the collated info.
			Collections.sort(vArr, cmpPT);
			Collections.sort(vArr, cmpPS);
			
			//Print
			for(ContestantLessMem x : vArr){
				// fmt: numPS ID PenaltyTime
				System.out.println(x.iD + " " + x.problemsSolved + " " + x.penaltyTime);
			}
			
			if(! (iCases == numberTestCases-1) ) {
				System.out.print("\n");
			}
			
		}
		
		scanner.close(); //CLOSE

	}

}


brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10258 - Contest Scoreboard

Post by brianfry713 » Thu Aug 28, 2014 1:00 am

Try input:

Code: Select all

1

100 1 1 C
AC output:

Code: Select all

100 1 1
Check input and AC output for thousands of problems on uDebug!

azisak
New poster
Posts: 4
Joined: Wed Aug 20, 2014 6:09 pm

Re: 10258 - Contest Scoreboard

Post by azisak » Fri Sep 12, 2014 7:55 am

Hi Guys, I need ur helps.
I got verdict WA with my code, can u suggest me how to fix it ?
Thanks !

Code: Select all

REMOVED AFTER AC  :D 
Last edited by azisak on Sat Sep 13, 2014 1:08 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10258 - Contest Scoreboard

Post by brianfry713 » Fri Sep 12, 2014 10:44 pm

Input:

Code: Select all

3

78 7 1 U
75 1 7 C
93 8 7 U
25 5 11 R
94 9 14 I
11 4 21 E
54 9 29 E
78 3 36 R
68 8 37 R
40 9 44 R
82 2 51 I
87 7 51 R
41 8 52 U
94 5 56 E
79 3 57 I
37 4 62 I
35 6 67 U
85 8 74 R
76 9 79 C
43 2 88 I
4 3 95 R
61 2 104 C
14 9 112 R
57 1 112 I
89 1 113 C
60 3 117 I
73 6 120 E
52 8 122 U
61 7 123 I
77 2 129 U
14 1 129 R
23 6 138 E
57 4 139 U
53 7 148 I
90 4 153 R
45 1 154 E
85 3 159 U
55 5 160 U
52 8 160 R
49 1 166 U
84 1 169 R
53 1 174 I
26 4 178 R
3 5 184 E
35 9 186 R
48 2 191 U
100 6 192 R
51 6 199 R
44 1 205 C
2 6 212 I
91 4 215 I
6 7 218 E
34 9 226 R
34 9 226 I
90 7 226 C
83 8 230 E
20 9 232 R
33 6 240 C
33 5 249 R
82 4 252 C
85 7 256 U
8 3 262 U
51 9 266 R
84 2 267 C
69 5 275 U
89 9 284 U
34 7 284 U
53 2 292 I
64 4 296 C
18 4 297 I
62 3 305 C
34 9 308 C
91 5 317 I
63 4 319 E
34 1 321 R
63 3 326 E
79 7 331 I
8 4 340 R
33 5 347 R
27 7 352 I
4 8 361 R
6 6 364 I
16 3 364 I
28 5 364 U
97 9 370 R
72 4 371 C
83 8 376 E
65 3 378 E
62 3 384 I
75 1 386 C
85 3 389 E
44 3 396 E
24 1 397 E
89 7 398 R
67 9 399 E
7 4 407 C
81 4 413 E
91 9 418 I
85 8 423 I
89 4 428 C
85 5 429 E
90 7 435 E
78 6 444 C
33 5 450 R
75 5 457 U
85 3 466 E
31 9 471 I
45 8 472 U
38 4 481 R
4 8 485 I
28 3 494 E
63 4 497 I
10 9 497 E
12 9 503 U
30 3 509 I
86 7 515 C
44 4 524 I
5 1 529 U
63 5 538 E
68 3 543 R
16 3 552 U
15 1 560 R
13 4 563 R
90 4 572 U
78 3 574 E
69 7 581 U
10 6 583 I
30 2 591 R
92 8 594 U
79 3 599 C
90 3 606 U
97 1 610 C
46 9 616 E
12 3 623 U
37 1 629 U
77 8 632 C
94 4 640 R
38 3 647 R
58 4 650 E
75 6 656 I
73 1 658 C
67 9 658 R
83 5 665 E
63 4 669 U
21 8 672 U
91 3 679 E
4 4 684 C
67 3 687 E
27 3 693 U
60 7 695 U
85 7 703 E
3 4 710 R
39 1 710 I
35 7 717 R
64 3 717 C
24 4 723 I
99 7 729 I
76 7 736 U
17 2 743 E
40 8 749 C
7 9 756 E
47 2 762 E
79 4 763 C
16 2 772 C
17 4 781 I
54 2 785 I
37 2 785 E
35 2 792 I
62 6 797 I
60 5 803 U
14 1 807 E
89 4 816 R
6 4 817 E
51 8 817 R
72 8 821 I
10 3 823 I
42 4 826 R
48 5 829 R
79 2 835 U
34 9 837 C
10 6 844 U
77 1 846 R
10 7 851 I
41 9 858 E
38 6 862 C
32 7 865 E
57 4 867 U
28 2 875 U
26 7 878 I
71 7 883 E
70 9 883 I
61 7 889 E
65 7 898 C
54 7 907 C
74 7 910 E
45 1 919 C
69 6 922 U
40 6 931 E
84 9 936 I
64 8 938 C
96 7 944 E
15 8 953 U
80 9 962 I
97 5 963 I
19 8 972 C
100 9 973 U
54 4 982 E
59 9 982 U

25 2 7 C
18 9 13 C
100 6 21 C
19 5 21 U
3 7 25 C
32 6 26 U
4 8 29 I
100 9 32 I
98 3 40 U
15 5 46 R
60 6 55 R
21 5 60 U
63 5 69 E
33 1 76 U
50 2 80 I
41 3 89 C
7 8 89 R
11 6 98 I
27 6 106 E
41 7 115 I
80 2 115 C
76 4 115 I
67 6 120 E
16 7 124 C
26 1 128 U
98 2 135 I
78 7 142 R
81 1 142 I
75 4 146 R
87 1 155 C
92 3 160 U
11 4 165 E
2 1 169 R
69 4 169 U
93 4 171 E
91 1 177 I
9 3 186 C
39 7 187 I
100 9 191 U
65 2 200 C
7 6 204 R
5 5 206 I
40 8 207 U
30 7 207 C
71 9 214 U
8 8 215 C
96 2 220 R
11 8 224 U
90 4 231 U
41 6 238 U
57 3 244 I
74 9 247 U
66 3 250 E
48 5 251 I
85 3 251 I
22 4 253 C
83 6 258 R
73 7 263 U
68 5 265 U
68 7 268 I
55 7 270 I
43 7 272 U
45 3 274 C
38 8 276 I
97 9 284 C
44 7 293 I
66 7 293 C
12 2 301 I
32 7 308 U
22 6 315 U
18 1 318 C
22 3 319 E
57 9 324 I
26 1 329 E
9 8 329 E
52 2 331 C
25 4 336 I
72 2 342 E
98 9 348 R
65 9 355 C
99 7 356 U
21 4 364 I
46 3 366 U
41 6 369 C
48 2 377 U
62 1 381 C
71 9 384 R
76 2 386 I
1 5 386 I
62 4 395 E
13 4 402 C
42 5 404 R
37 3 406 U
54 3 414 U
20 6 419 C
64 6 420 E
97 8 427 U
43 2 429 C
89 3 435 U
70 6 442 E
11 4 451 E
98 5 451 R
14 2 460 E
21 8 460 E
12 4 467 R
64 1 474 I
27 7 481 R
6 9 484 C
88 4 489 I
86 2 494 C
75 3 495 I
7 1 502 I
51 6 502 R
89 6 503 C
64 1 512 E
63 1 517 R
35 7 525 C
92 9 532 U
57 1 539 I
23 4 548 I
15 9 551 C
53 4 551 E
67 2 552 I
5 3 555 R
92 4 557 I
54 7 563 U
86 6 567 E
37 4 567 C
75 4 569 I
33 9 570 R
14 2 578 U
55 9 578 C
78 2 579 E
59 3 581 C
95 2 583 C
85 2 585 I
57 3 588 U
21 2 588 C
12 9 588 C
84 4 588 U
88 4 590 C
81 3 598 C
15 4 600 I
29 1 603 C
81 5 603 E
77 1 609 I
39 2 615 C
4 3 623 R
21 3 625 C
26 2 628 R
75 7 629 R
75 9 633 R
98 9 634 C
85 7 640 U
85 6 645 C
48 3 647 R
18 2 649 I
2 9 649 R
36 1 650 R
82 9 659 I
42 9 662 E
25 9 671 I
97 5 675 I
32 8 683 E
54 9 685 U
39 6 692 U
13 2 692 E
92 8 699 U
39 9 706 C
59 3 710 R
13 7 713 C
60 8 719 C
5 5 724 C
22 1 733 C
25 4 739 R
15 2 744 U
91 9 750 I
32 9 755 I
21 5 758 I
26 4 766 R
29 3 773 C
75 1 780 I
48 1 780 C
73 6 786 R
87 6 786 R
30 9 792 E
34 5 794 I
96 6 802 R
98 8 809 U
55 9 810 U
32 7 813 I
59 3 821 C
21 5 825 E
9 1 830 R
92 3 833 I
64 8 837 I
4 8 846 C
59 2 849 U
47 4 855 C
63 4 862 C
51 2 867 U
5 5 868 E
73 5 876 I
95 9 879 R
100 6 883 U
41 7 886 U
47 1 895 I
65 9 902 C
73 5 911 C
20 1 912 R
36 2 912 U
22 1 917 I
15 5 918 I
12 5 918 C
31 6 919 C
94 2 921 C
49 7 928 U
75 6 930 I
43 4 934 U
78 7 940 E
18 8 945 I
100 4 951 R
93 3 960 C
30 8 960 I
84 3 961 U
76 1 970 R
60 4 973 C
92 1 977 C
40 4 980 U
88 8 987 E
44 2 988 R
43 6 997 E
69 2 1006 R
65 3 1007 I
73 4 1013 R
28 7 1017 C
38 7 1017 E
98 3 1023 E
83 7 1024 C
92 1 1026 U
20 9 1033 C
100 4 1034 C
85 6 1043 I
31 5 1051 E
78 8 1052 R
77 1 1055 I
29 2 1059 R
1 1 1060 U
35 3 1063 C
78 9 1068 C
100 8 1076 I
54 3 1078 E
2 6 1086 I
55 6 1094 R
58 8 1098 E
21 8 1105 C
89 5 1106 E
56 4 1110 I
94 3 1119 U
14 3 1124 C
88 2 1131 E
64 7 1137 C
64 3 1141 R
26 2 1143 C
97 2 1143 I
84 4 1147 U
70 8 1151 R
83 3 1154 C
44 4 1159 E
81 1 1165 R
74 1 1174 E
22 1 1183 C
56 4 1184 R
15 5 1184 I
25 2 1193 R

72 4 1 U
42 6 8 C
33 4 11 C
77 2 17 C
76 9 23 R
8 5 28 C
66 8 34 R
1 9 42 E
52 9 44 E
60 9 50 E
87 1 50 E
41 4 51 C
44 2 58 R
17 7 66 U
17 2 72 R
79 4 78 C
58 1 79 R
70 4 88 U
81 3 97 U
61 9 100 I
55 9 104 I
18 8 113 R
8 6 114 U
100 2 119 I
71 9 120 I
91 1 121 R
46 2 123 U
56 8 132 U
12 5 141 C
77 3 146 I
83 3 152 I
61 3 159 I
84 9 159 I
62 1 168 U
96 3 171 C
21 2 171 R
10 7 175 R
83 7 180 U
50 6 189 R
88 8 194 E
62 7 194 E
46 1 203 C
83 6 205 R
38 7 206 R
51 3 210 R
83 8 213 C
55 2 220 R
44 9 221 C
11 8 230 U
53 1 230 C
18 6 234 R
97 4 236 I
84 8 236 U
98 6 244 E
40 2 250 E
88 8 256 E
70 2 265 C
87 7 267 C
48 6 272 E
32 1 272 E
54 7 275 E
68 2 275 R
81 7 279 C
61 2 280 I
6 3 283 I
81 3 286 E
15 9 289 I
24 7 297 U
50 9 306 U
31 1 312 E
88 8 316 R
55 3 316 U
21 8 322 C
1 6 326 C
62 9 327 C
25 4 332 U
75 3 338 U
80 5 340 I
46 7 343 C
43 1 348 U
86 2 356 I
20 1 362 E
50 3 366 I
45 5 372 R
28 5 374 U
75 6 383 U
37 2 383 I
94 9 387 I
1 3 389 R
6 3 397 C
37 8 405 E
57 4 409 R
37 4 414 I
70 3 421 U
65 5 421 I
35 1 423 R
91 3 432 E
77 2 438 U
89 6 440 I
21 9 443 R
28 4 451 R
97 6 457 U
53 7 457 E
74 6 459 R
21 2 462 C
51 8 467 C
98 7 469 U
59 5 469 C
47 5 477 U
50 4 484 C
32 8 493 E
43 6 501 R
58 6 501 C
96 9 502 R
86 5 507 U
54 2 512 E
43 4 515 E
11 5 524 U
29 2 524 I
12 6 525 E
3 9 534 E
23 4 541 U
12 6 547 R
50 7 553 I
64 8 555 U
15 2 559 E
25 3 560 R
39 2 566 C
97 5 575 R
14 3 580 U
37 1 580 I
34 5 589 I
81 5 593 E
100 9 599 E
56 2 606 E
4 2 610 C
6 8 619 E
57 8 623 U
46 6 629 E
13 6 634 R
81 2 638 E
85 8 643 E
35 8 651 E
AC output:

Code: Select all

64 3 1951
89 2 541
79 2 1382
75 1 7
76 1 79
61 1 104
44 1 205
90 1 226
33 1 240
82 1 252
84 1 267
62 1 305
34 1 328
72 1 371
7 1 407
78 1 444
86 1 515
97 1 610
77 1 632
73 1 658
4 1 684
40 1 749
16 1 772
38 1 862
65 1 898
54 1 907
45 1 919
19 1 972
2 0 0
3 0 0
5 0 0
6 0 0
8 0 0
10 0 0
11 0 0
12 0 0
13 0 0
14 0 0
15 0 0
17 0 0
18 0 0
20 0 0
21 0 0
23 0 0
24 0 0
25 0 0
26 0 0
27 0 0
28 0 0
30 0 0
31 0 0
32 0 0
35 0 0
37 0 0
39 0 0
41 0 0
42 0 0
43 0 0
46 0 0
47 0 0
48 0 0
49 0 0
51 0 0
52 0 0
53 0 0
55 0 0
57 0 0
58 0 0
59 0 0
60 0 0
63 0 0
67 0 0
68 0 0
69 0 0
70 0 0
71 0 0
74 0 0
80 0 0
81 0 0
83 0 0
85 0 0
87 0 0
91 0 0
92 0 0
93 0 0
94 0 0
96 0 0
99 0 0
100 0 0

21 3 2318
18 2 331
41 2 458
65 2 555
22 2 986
100 2 1055
13 2 1115
39 2 1321
29 2 1376
20 2 1452
12 2 1506
35 2 1588
60 2 1692
83 2 2178
25 1 7
3 1 25
80 1 115
16 1 124
87 1 155
9 1 186
30 1 207
8 1 215
45 1 274
97 1 284
66 1 293
52 1 331
62 1 381
43 1 429
6 1 484
86 1 494
89 1 503
15 1 551
37 1 567
55 1 578
59 1 581
95 1 583
81 1 598
88 1 610
98 1 634
85 1 645
5 1 744
48 1 780
47 1 855
63 1 862
4 1 866
31 1 919
94 1 921
73 1 931
93 1 960
92 1 977
28 1 1017
78 1 1068
14 1 1124
64 1 1137
26 1 1143
1 0 0
2 0 0
7 0 0
11 0 0
19 0 0
23 0 0
27 0 0
32 0 0
33 0 0
34 0 0
36 0 0
38 0 0
40 0 0
42 0 0
44 0 0
46 0 0
49 0 0
50 0 0
51 0 0
53 0 0
54 0 0
56 0 0
57 0 0
58 0 0
67 0 0
68 0 0
69 0 0
70 0 0
71 0 0
72 0 0
74 0 0
75 0 0
76 0 0
77 0 0
82 0 0
84 0 0
90 0 0
91 0 0
96 0 0
99 0 0

46 2 546
21 2 784
42 1 8
33 1 11
77 1 17
8 1 28
41 1 51
79 1 78
12 1 141
96 1 171
83 1 213
44 1 221
53 1 230
70 1 265
87 1 267
81 1 279
1 1 326
62 1 327
6 1 417
51 1 467
59 1 469
50 1 484
58 1 501
39 1 566
4 1 610
3 0 0
10 0 0
11 0 0
13 0 0
14 0 0
15 0 0
17 0 0
18 0 0
20 0 0
23 0 0
24 0 0
25 0 0
28 0 0
29 0 0
31 0 0
32 0 0
34 0 0
35 0 0
37 0 0
38 0 0
40 0 0
43 0 0
45 0 0
47 0 0
48 0 0
52 0 0
54 0 0
55 0 0
56 0 0
57 0 0
60 0 0
61 0 0
64 0 0
65 0 0
66 0 0
68 0 0
71 0 0
72 0 0
74 0 0
75 0 0
76 0 0
80 0 0
84 0 0
85 0 0
86 0 0
88 0 0
89 0 0
91 0 0
94 0 0
97 0 0
98 0 0
100 0 0
Check input and AC output for thousands of problems on uDebug!

azisak
New poster
Posts: 4
Joined: Wed Aug 20, 2014 6:09 pm

Re: 10258 - Contest Scoreboard

Post by azisak » Sat Sep 13, 2014 1:09 am

Thanks very much brianfry, finally ac after a long time huhhh

s0mbra
New poster
Posts: 4
Joined: Thu Dec 11, 2014 9:30 pm

Re: 10258 - Contest Scoreboard

Post by s0mbra » Thu Dec 11, 2014 9:33 pm

I'd like to warn the ones who are getting WA that the last case must not print an blank line. I was getting WA, besides getting correct answers for the tests posted here, until i removed the comand to print this last blank line.

uohzxela
New poster
Posts: 4
Joined: Thu Jan 01, 2015 2:51 pm

Re: 10258 - Contest Scoreboard

Post by uohzxela » Thu Jan 01, 2015 2:53 pm

Code: Select all

import java.io.PrintWriter;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

class Main {
	public static void main(String args[]) {
		PrintWriter out = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int numCases = Integer.parseInt(sc.nextLine());
		sc.nextLine();
		for (int i = 0; i < numCases; i++) {
			HashMap<Integer, Contestant> ranking = new HashMap<Integer, Contestant>();
			while (true) {
				String input = sc.nextLine();
				if(input.equals("")) break;
				String[] inputArr = input.split(" ");
				int contestantId = Integer.parseInt(inputArr[0]);
				int probId = Integer.parseInt(inputArr[1]);
				int time = Integer.parseInt(inputArr[2]);
				String type = inputArr[3];
//				out.printf("%d %d %d %s\n", contestantId, probId, time,
//						type);
				if(ranking.get(contestantId) == null) {
					Contestant c =  new Contestant(contestantId);
					c.adjustScore(probId, time, type);
					ranking.put(contestantId, c);
					
				} else {
					Contestant c = ranking.get(contestantId);
					c.adjustScore(probId, time, type);
				}
			}
			
			ValueComparator vc = new ValueComparator(ranking);
			TreeMap<Integer, Contestant> sorted_ranking = new TreeMap<Integer, Contestant>(vc);
			sorted_ranking.putAll(ranking);
			for (Map.Entry<Integer, Contestant> entry : sorted_ranking.entrySet()) {
//				System.out.println("Key : " + entry.getKey() 
//	                                      + " Value : " + entry.getValue().penaltyTime);
				out.printf("%d %d %d\n", entry.getKey(), entry.getValue().numSolved, entry.getValue().penaltyTime);
			}
			if(i<numCases-1) {
				out.print("\n");
			}

		}
		out.close();
	}
	public static void printMap(Map<Integer, Contestant> ranking) {
		for (Map.Entry<Integer, Contestant> entry : ranking.entrySet()) {
//			System.out.println("Key : " + entry.getKey() 
//                                      + " Value : " + entry.getValue().penaltyTime);
			System.out.printf("%d %d %d\n", entry.getKey(), entry.getValue().numSolved, entry.getValue().penaltyTime);
		}
	}
}

class ValueComparator implements Comparator<Integer> {
	Map<Integer, Contestant> base;
	public ValueComparator(Map<Integer, Contestant> base) {
		this.base = base;
	}
	@Override
	public int compare(Integer a, Integer b) {
		Contestant c1 = base.get(a);
		Contestant c2 = base.get(b);
		
		if(c1.numSolved > c2.numSolved) {
			return -1;
		} else if(c1.numSolved < c2.numSolved) {
			return 1;
		} else {
			if(c1.penaltyTime > c2.penaltyTime) {
				return 1;
			} else if(c1.penaltyTime < c2.penaltyTime) {
				return -1;
			} else {
				Integer c1Id = c1.id;
				Integer c2Id = c2.id;
				return c1Id.compareTo(c2Id);
			}
		}
	}
	
}

class Contestant {
	int id;
	int numSolved;
	int penaltyTime;
	HashMap<Integer, Boolean> solvedProbs;
	int[] probPenaltyTime;

	public Contestant(int id) {
		this.id = id;
		numSolved = 0;
		penaltyTime = 0;
		solvedProbs = new HashMap<Integer, Boolean>();
		probPenaltyTime = new int[100];
		
	}

	public void adjustScore(int probId, int time, String type) {
		if (solvedProbs.get(probId) == null) {
			if (type.equals("C")) {
				penaltyTime += time + probPenaltyTime[probId-1];
				numSolved++;
				solvedProbs.put(probId, true);
			}
			if (type.equals("I")) {
//				penaltyTime += 20;
				probPenaltyTime[probId-1] += 20;
			}
		}
	}
}
I got the same output as all the sample output in this thread but when I submitted my code I got RE. Any ideas?

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 10258 - Contest Scoreboard

Post by lighted » Sat Jan 03, 2015 11:48 am

Your code have problem with parsing input. You should check if input stream has next line, otherwise you get RE. Change line to

Code: Select all

while (sc.hasNextLine()) {
    String input = sc.nextLine();
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Post Reply

Return to “Volume 102 (10200-10299)”