## 1612 - Guess

Moderator: Board moderators

Repon kumar Roy
Learning poster
Posts: 96
Joined: Tue Apr 23, 2013 12:54 pm

### 1612 - Guess

Code: Select all

``````
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define inf 1000000000
using namespace std;
#define N 16385
int pos[N];
double permu[N][8],a,maxi,x,y,z;
int main(int argc, const char * argv[])
{

int n,i,pos1,pos2,j,flag,cases=0;
while (scanf("%d",&n)==1 && n) {
memset(permu, 0, sizeof(permu));
for (i=1; i<=n; i++) {

cin>>x>>y>>z;
permu[i][0]=0 ; permu[i][1] = x; permu[i][2] = y; permu[i][3]= z; permu[i][4] = x+y;
permu[i][5]=y+z;permu[i][6] = x+z; permu[i][7] =x+y+z;
sort(permu[i],permu[i]+8);
}
for (i=1; i<=n; i++) {
cin>>pos[i];
}
a = permu[pos[1]][7];
flag=1;
for(i=1;i<n;i++){
pos1=pos[i];
pos2= pos[i+1];
flag=0;
maxi = -inf;
if(pos1<pos2){
for (j=0; j<8; j++) {
if( permu[pos2][j] <= a){
flag=1;
if(permu[pos2][j]>maxi) maxi = permu[pos2][j];
}
}
}
else {
for (j=0; j<8; j++) {
if( permu[pos2][j] < a){
flag=1;
if(permu[pos2][j]>maxi) maxi = permu[pos2][j];
}
}
}
if(flag==0) break;
else a=maxi;
}
printf("Case %d: ",++cases);
if(flag==0) cout<<"No solution\n";
else printf("%.2lf\n",a);
}
return 0;
}

``````
Getting WA ... Help needed!!! I have tested all your(Brainfry713) input and this time it is all the same . I submitted this code but again WA .
Last edited by Repon kumar Roy on Fri Jan 10, 2014 11:06 pm, edited 1 time in total.

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

### Re: 1612 - Guess

Input:

Code: Select all

``````9
294.39 53.90 58.26
303.15 877.60 934.21
732.19 259.55 828.42
972.64 655.47 924.72
935.01 129.39 374.39
33.33 719.94 727.29
35.83 125.19 354.65
834.37 335.15 778.80
423.69 115.58 961.67
5 9 1 7 3 2 8 6 4
9
669.54 145.63 889.60
30.11 852.52 379.17
733.65 901.20 846.67
10.72 434.02 732.59
321.20 982.51 2.83
464.30 775.10 232.12
58.99 48.95 547.44
170.71 851.04 818.79
426.69 287.02 82.84
6 4 8 5 9 7 1 3 2
7
763.69 501.16 725.85
684.49 107.14 218.49
189.88 534.55 852.12
511.77 567.58 75.88
248.04 601.97 230.00
143.43 655.73 741.39
714.99 284.13 292.70
5 1 4 2 3 7 6
6
186.11 5.75 782.38
84.97 658.36 441.05
552.34 105.57 239.98
979.77 160.65 478.76
604.42 908.97 993.81
597.37 201.86 80.25
1 6 5 3 4 2
10
664.08 421.30 603.11
372.49 591.42 936.73
7.38 820.65 930.22
877.17 162.40 716.24
525.84 501.72 656.11
540.68 923.80 947.40
926.85 82.77 694.87
398.79 523.08 207.06
31.69 322.14 155.82
976.33 924.40 780.00
10 2 3 6 7 8 9 4 5 1
9
784.34 476.76 327.70
649.73 234.35 266.51
425.23 460.33 443.08
28.35 833.53 209.84
66.72 936.24 584.14
280.23 163.93 195.86
671.09 482.98 375.47
690.78 517.14 517.84
186.00 47.51 714.94
7 3 9 2 6 4 8 1 5
10
888.03 896.13 404.16
718.22 817.49 538.94
763.85 326.48 891.84
29.59 763.63 232.77
925.34 179.84 463.85
32.98 534.29 950.21
944.13 623.70 344.74
20.23 742.35 797.93
264.15 520.04 700.05
765.32 233.79 700.49
8 10 2 4 9 6 5 3 7 1
7
926.72 933.91 475.88
903.48 532.99 748.75
951.16 602.19 616.52
784.53 698.16 900.87
363.09 761.01 644.37
462.31 351.38 797.08
11.43 928.10 758.29
5 7 3 6 2 4 1
7
507.01 887.23 196.37
623.55 538.08 346.24
276.88 149.61 405.98
849.41 59.38 598.78
124.38 650.28 937.95
373.14 380.72 127.57
679.29 499.71 791.39
7 5 1 3 6 2 4
5
252.16 169.03 874.58
557.43 415.81 405.64
954.37 156.29 823.24
705.09 246.26 628.95
417.16 658.41 788.21
5 3 1 4 2
7
228.63 812.61 230.07
160.01 331.04 220.08
153.81 149.07 755.20
885.79 247.27 838.58
437.40 542.59 396.15
682.12 404.19 447.91
55.03 636.54 120.32
5 1 6 3 7 4 2
1
24.62 882.87 430.35
1
10
735.73 550.92 836.10
123.26 962.39 292.98
259.35 237.59 580.34
226.89 737.14 797.12
390.86 606.66 172.72
851.47 351.26 796.07
821.11 225.95 697.86
388.34 459.01 445.48
927.35 384.86 946.18
737.17 329.51 759.63
1 3 4 9 10 8 7 2 5 6
6
572.90 289.18 645.40
498.22 819.60 476.00
229.21 518.78 810.55
205.64 919.19 639.99
776.55 718.42 192.17
863.37 534.73 496.15
5 1 6 4 3 2
6
197.34 47.75 964.69
752.05 947.88 34.28
852.92 646.44 874.04
837.94 547.00 660.74
835.74 453.74 4.62
985.42 546.99 395.19
1 5 3 4 6 2
7
495.25 332.50 227.35
701.99 236.55 352.84
479.67 499.05 14.73
669.85 485.75 738.34
167.64 194.92 380.23
971.83 421.94 51.71
575.55 423.23 919.16
6 4 2 7 5 3 1
2
557.84 604.88 147.66
169.80 621.02 164.27
2 1
3
535.34 238.15 266.15
271.82 489.90 958.14
469.25 190.03 264.30
1 3 2
4
474.24 990.00 370.73
232.12 402.66 245.70
77.65 905.67 751.70
423.88 570.59 506.47
4 2 1 3
6
21.36 993.68 513.68
813.58 506.95 960.83
517.21 278.98 70.08
753.44 835.94 486.35
877.63 31.29 632.05
979.76 646.43 983.26
6 3 2 4 5 1
8
741.57 726.20 78.28
924.79 189.80 244.43
372.68 471.09 837.42
683.92 796.07 346.01
165.78 66.47 12.75
953.36 836.44 558.16
277.20 157.97 231.77
334.86 695.14 363.34
4 8 3 1 2 6 5 7
1
145.74 619.29 509.88
1
8
45.10 223.14 981.70
181.54 50.66 420.21
311.20 202.19 901.16
509.07 258.46 446.34
235.95 970.90 468.99
478.89 313.16 765.47
752.64 177.98 762.59
325.82 429.53 680.10
6 1 7 4 8 2 3 5
8
547.77 46.99 742.51
571.23 153.12 545.12
810.26 79.00 922.15
684.57 345.92 32.11
127.64 891.75 481.13
198.62 720.69 115.21
119.79 832.43 326.19
419.25 208.41 746.55
2 6 5 4 7 3 1 8
1
714.54 558.41 826.42
1
6
865.58 374.87 787.75
90.98 588.44 590.17
907.76 401.67 906.29
42.90 13.92 591.52
502.22 917.36 768.07
48.24 482.89 898.43
2 3 6 1 5 4
9
223.64 106.46 663.87
108.82 258.66 917.14
951.59 441.76 642.53
825.37 585.49 854.43
600.81 975.18 37.33
680.27 962.16 920.16
232.03 703.49 393.37
137.97 40.26 656.63
681.26 192.92 41.91
9 3 5 7 4 1 2 6 8
5
196.06 536.03 917.56
208.25 70.99 862.86
698.56 785.05 65.96
639.17 162.76 600.29
532.97 736.78 257.32
5 4 3 1 2
10
797.62 470.27 511.08
231.28 913.45 622.95
875.07 922.12 978.21
195.76 148.59 646.91
374.62 350.59 461.45
300.44 967.37 222.40
202.05 562.22 540.17
540.48 858.33 126.45
115.40 544.38 292.85
190.88 151.76 438.92
6 4 7 1 9 5 3 8 2 10
3
129.33 525.44 506.79
560.25 172.21 33.35
955.08 160.27 118.68
2 1 3
6
720.29 657.10 429.42
928.25 819.21 946.25
946.89 545.61 202.15
742.30 478.24 461.66
698.06 812.50 42.57
256.58 572.27 600.10
2 3 6 1 5 4
1
724.66 555.34 621.94
1
2
219.15 563.25 185.85
272.16 585.21 758.21
1 2
8
414.64 8.27 820.99
241.72 442.20 178.62
845.33 953.08 79.77
181.82 206.08 410.38
366.27 132.19 203.64
3.87 928.38 227.49
58.44 962.33 149.42
422.26 316.89 173.56
6 5 1 2 4 7 3 8
7
820.92 550.71 574.22
443.86 716.49 831.29
314.29 161.58 719.17
791.93 812.30 619.34
167.97 251.12 578.29
738.74 661.93 172.90
107.71 582.21 203.81
2 5 4 3 6 7 1
1
223.72 501.80 279.88
1
1
571.55 700.81 287.51
1
3
501.66 638.46 232.00
613.78 18.72 0.11
303.16 857.15 514.49
2 3 1
7
620.59 411.86 971.08
776.66 336.91 66.64
546.68 488.94 957.35
791.88 226.25 239.61
856.33 496.08 997.41
439.57 739.28 293.53
823.09 255.05 521.11
4 2 5 7 1 3 6
4
192.28 524.48 240.98
860.10 213.52 377.17
479.64 958.40 155.66
808.47 276.84 85.21
4 2 3 1
7
760.33 530.60 941.80
604.90 123.52 913.54
857.08 555.17 152.37
321.10 887.37 872.65
422.04 823.81 309.63
249.67 419.15 385.59
805.97 484.62 674.80
1 4 7 5 6 2 3
6
478.52 146.04 490.59
733.65 485.59 461.62
402.70 668.01 702.96
721.93 684.16 644.48
296.22 735.79 280.25
290.80 7.38 933.03
3 6 5 4 1 2
10
445.95 683.23 827.30
235.32 2.41 695.85
837.45 754.15 209.23
202.07 541.70 148.03
579.90 287.48 993.84
606.08 832.59 672.08
386.47 71.54 793.29
540.77 821.95 223.06
900.74 132.40 380.10
35.97 335.93 458.87
8 9 3 10 6 4 2 1 7 5
9
972.83 348.76 60.42
257.45 531.64 613.69
402.29 351.57 619.64
848.85 305.89 879.38
233.98 20.68 27.83
929.41 387.45 41.10
239.94 575.94 263.59
992.61 989.11 810.32
908.09 532.71 552.91
1 6 2 9 3 5 8 4 7
10
35.25 212.20 14.31
992.33 698.30 301.06
58.66 253.06 475.61
512.84 385.67 751.77
757.23 311.29 537.73
849.19 762.71 754.90
283.27 980.50 777.98
977.94 478.58 88.72
212.08 508.28 171.88
924.92 502.49 581.20
1 9 5 2 4 7 3 8 6 10
4
127.47 451.17 306.27
184.64 170.56 793.82
849.58 51.48 224.78
156.37 164.25 402.53
2 4 1 3
3
584.95 612.15 688.33
520.87 345.12 94.63
805.27 898.05 203.68
1 2 3
8
640.29 370.32 340.54
538.00 103.50 315.69
979.27 255.33 412.70
69.93 839.66 525.19
786.93 54.49 643.96
807.70 545.26 799.61
274.94 388.22 791.38
866.71 812.38 916.26
6 7 1 4 3 5 2 8
1
397.67 724.84 280.31
1
5
837.33 353.46 295.45
999.51 102.83 573.27
365.59 358.23 15.40
330.52 589.99 521.01
64.00 445.14 233.21
3 2 5 4 1
1
832.39 469.78 556.44
1
3
199.31 514.88 972.91
672.74 279.20 432.79
557.40 275.05 95.61
3 2 1
6
387.90 298.57 933.02
544.72 440.19 481.67
11.18 679.27 338.80
480.10 71.85 849.99
587.81 886.73 437.29
362.82 3.20 883.93
4 6 5 2 3 1
7
225.52 85.55 221.58
588.75 834.26 651.96
858.42 39.25 404.14
924.91 499.42 988.26
967.47 705.25 733.61
793.90 381.40 905.74
871.73 736.96 439.58
2 5 1 6 7 4 3
1
578.53 456.02 962.57
1
9
101.22 86.75 803.38
144.56 334.34 663.91
204.76 398.80 252.73
818.77 668.06 103.37
50.44 82.72 39.26
976.21 480.53 383.52
447.46 768.91 812.33
527.69 793.51 271.12
60.27 607.83 359.49
6 2 9 8 3 7 4 1 5
10
165.58 481.00 672.53
935.90 271.63 726.72
315.85 202.56 135.22
700.70 597.95 444.85
333.19 494.88 119.97
315.57 674.57 924.73
32.52 854.41 229.91
4.28 98.19 526.89
671.63 460.49 265.65
913.06 301.42 912.61
6 4 5 8 1 10 3 7 2 9
2
604.06 645.85 379.03
762.52 860.61 634.95
1 2
6
786.87 927.27 834.33
28.66 30.70 122.41
532.78 504.77 125.77
624.20 790.29 263.84
158.43 28.85 181.76
831.55 523.44 728.43
3 6 1 2 4 5
2
427.08 288.49 504.59
263.34 702.43 244.72
2 1
4
687.73 91.91 163.96
223.49 826.62 17.19
65.78 202.06 154.23
877.06 418.05 879.58
1 3 2 4
8
404.25 760.12 610.64
5.16 22.91 799.03
34.24 524.28 17.49
156.33 136.51 802.26
317.93 217.85 339.54
404.70 479.79 357.67
372.48 678.03 673.35
913.73 911.89 897.83
8 2 3 6 4 5 7 1
2
378.63 185.59 994.92
93.98 716.57 942.94
2 1
3
15.39 807.26 790.23
700.63 368.81 812.18
945.43 725.01 2.68
3 2 1
1
93.42 28.76 32.34
1
7
606.73 810.80 483.87
255.76 688.74 312.69
108.93 876.55 139.08
535.43 24.53 36.53
5.21 138.12 427.10
113.71 197.88 708.17
253.80 130.77 840.04
4 3 5 1 2 6 7
2
742.68 847.06 625.70
659.69 448.54 96.57
1 2
9
593.18 964.01 862.99
466.85 346.26 148.41
806.31 31.83 578.42
610.79 677.53 937.08
723.44 594.58 685.25
308.59 877.38 195.24
694.50 649.09 252.23
707.27 451.24 744.67
676.65 262.45 136.09
2 3 9 5 6 1 8 4 7
7
370.65 309.17 942.48
769.34 164.72 766.18
32.46 496.96 37.89
191.84 170.49 260.93
845.30 294.80 119.84
257.87 18.39 478.00
609.22 764.23 257.40
5 2 4 3 7 6 1
5
555.89 75.64 904.53
532.38 605.87 508.11
281.08 228.72 169.58
266.88 84.04 566.68
557.62 48.12 551.18
3 4 2 5 1
5
563.73 63.05 134.02
1.30 274.73 706.53
405.67 501.21 11.83
423.98 392.23 933.41
568.20 574.90 107.06
2 5 4 1 3
1
270.14 286.95 741.28
1
7
398.06 188.79 205.15
882.91 969.84 547.93
261.23 734.41 349.44
330.22 709.88 144.03
596.77 223.26 63.37
859.32 322.01 444.91
401.46 757.58 225.73
1 2 5 7 4 6 3
6
364.44 742.34 522.32
638.36 607.90 907.31
650.12 873.91 280.50
161.36 703.60 489.46
290.56 378.64 679.94
8.83 709.64 89.23
3 6 2 4 1 5
4
295.97 898.83 372.07
172.50 661.84 895.01
260.74 439.51 996.23
884.07 245.01 697.81
1 3 4 2
3
710.96 56.75 272.49
141.40 208.05 593.07
517.86 44.66 790.69
1 2 3
10
714.16 809.30 857.64
789.51 286.65 449.14
82.14 323.37 807.13
712.44 174.22 322.80
10.72 709.98 588.40
836.98 21.67 988.91
36.03 605.85 564.88
662.92 883.96 816.46
881.98 887.37 524.65
893.52 801.69 890.51
5 2 8 1 7 4 10 9 6 3
3
736.68 955.40 151.09
736.88 155.99 812.38
438.29 345.69 387.94
2 3 1
5
950.41 340.18 76.57
50.07 358.98 197.06
534.05 987.70 714.99
961.07 474.22 60.86
524.51 234.91 152.43
2 4 3 5 1
9
217.40 391.07 490.94
456.12 217.68 790.50
669.21 886.94 398.74
698.25 846.12 582.93
156.55 457.68 402.97
739.92 265.98 549.58
746.64 303.81 795.82
765.24 953.44 838.59
577.16 87.00 418.74
6 9 1 7 2 3 8 4 5
6
27.84 704.80 649.13
581.46 683.91 787.85
75.26 945.05 851.28
156.02 575.91 265.45
463.75 241.31 860.54
597.44 60.13 440.28
4 3 5 6 2 1
3
311.90 421.33 945.63
979.63 540.76 888.96
666.62 127.39 369.96
3 2 1
7
684.95 5.02 555.56
746.93 23.01 177.41
876.10 172.88 714.08
61.99 79.91 750.48
518.21 937.75 278.71
69.34 350.74 629.96
891.02 187.98 727.34
1 6 3 7 4 5 2
3
607.21 963.46 270.83
853.73 875.34 700.86
700.89 622.79 903.71
2 1 3
9
499.82 185.42 719.48
642.53 666.19 817.11
115.54 171.63 16.12
644.53 710.89 829.05
502.87 689.85 427.89
608.73 234.74 687.40
479.50 105.26 684.85
153.85 514.47 914.99
787.01 371.82 591.30
6 9 7 8 4 1 5 3 2
4
303.96 289.66 610.81
920.04 898.05 153.67
948.48 250.05 118.97
245.38 372.50 471.33
1 4 2 3
6
657.68 231.38 306.98
965.21 940.60 316.20
243.44 936.37 425.38
793.68 771.91 644.86
320.49 787.38 306.96
246.30 822.26 299.32
1 5 2 4 3 6
5
706.21 346.10 533.09
170.83 485.50 360.41
578.66 669.77 979.78
760.73 967.78 550.89
858.96 128.63 204.13
4 2 5 3 1
2
230.35 925.45 733.65
881.35 740.60 606.61
1 2
4
356.86 189.43 761.22
730.87 235.19 691.55
39.95 127.74 144.00
78.22 0.17 692.12
2 3 4 1
4
2.43 887.58 381.64
229.72 535.58 629.28
785.03 223.11 359.71
846.43 915.77 451.51
4 2 3 1
4
25.80 217.66 446.01
89.04 237.79 323.56
982.88 895.70 977.72
296.95 822.19 544.19
1 2 4 3
6
145.17 461.78 770.08
253.72 487.22 749.31
12.05 849.42 728.24
466.90 215.46 746.44
609.27 127.14 637.37
948.01 10.79 388.32
3 5 1 2 6 4
2
907.97 328.50 148.34
943.09 39.53 94.93
1 2
10
310.81 60.26 972.80
532.61 1.72 312.00
900.80 658.13 958.86
273.89 156.28 282.06
522.38 263.65 843.02
427.31 140.94 71.62
1.84 475.40 283.02
743.80 272.11 222.59
567.47 105.25 39.24
548.64 43.10 501.78
8 6 5 4 7 10 2 9 3 1
1
596.96 208.33 22.49
1
3
462.17 868.57 340.29
236.46 268.92 284.67
566.18 111.54 947.32
3 2 1
9
623.32 258.90 758.57
264.58 650.72 729.66
618.97 173.81 778.59
963.01 954.16 517.66
607.48 26.82 365.08
850.15 475.17 457.85
841.35 23.31 533.51
868.20 620.71 895.87
638.92 607.37 786.90
2 3 1 8 9 4 7 6 5
3
812.90 331.27 839.81
595.04 807.48 665.14
154.15 998.15 925.78
3 2 1
7
26.53 729.47 397.25
229.98 697.90 317.84
537.95 789.72 481.76
119.32 436.42 254.89
461.69 957.86 382.51
763.75 3.10 194.04
878.57 771.80 760.81
7 1 3 4 5 2 6
``````
AC output:

Code: Select all

``````Case 1: No solution
Case 2: No solution
Case 3: No solution
Case 4: 441.05
Case 5: No solution
Case 6: No solution
Case 7: 404.16
Case 8: 475.88
Case 9: 598.78
Case 10: 821.45
Case 11: 220.08
Case 12: 1337.84
Case 13: 0.00
Case 14: 974.22
Case 15: 34.28
Case 16: 495.25
Case 17: 752.54
Case 18: 761.72
Case 19: 829.35
Case 20: 535.04
Case 21: No solution
Case 22: 1274.91
Case 23: 468.99
Case 24: 0.00
Case 25: 2099.37
Case 26: 648.34
Case 27: 0.00
Case 28: 279.24
Case 29: No solution
Case 30: 278.95
Case 31: 742.30
Case 32: 1901.94
Case 33: 857.37
Case 34: 0.00
Case 35: 574.22
Case 36: 1005.40
Case 37: 1559.87
Case 38: 501.66
Case 39: 439.57
Case 40: 957.74
Case 41: 1009.45
Case 42: 485.59
Case 43: No solution
Case 44: No solution
Case 45: No solution
Case 46: 276.26
Case 47: 898.05
Case 48: 0.00
Case 49: 1402.82
Case 50: 295.45
Case 51: 1858.61
Case 52: 514.88
Case 53: 686.47
Case 54: No solution
Case 55: 1997.12
Case 56: 89.70
Case 57: 0.00
Case 58: 1623.13
Case 59: 0.00
Case 60: 931.67
Case 61: 0.00
Case 62: No solution
Case 63: 1559.14
Case 64: 822.65
Case 65: 154.52
Case 66: 0.00
Case 67: 1204.80
Case 68: No solution
Case 69: 0.00
Case 70: 555.89
Case 71: 11.83
Case 72: 1298.37
Case 73: No solution
Case 74: 290.56
Case 75: 1067.51
Case 76: 835.35
Case 77: No solution
Case 78: 1106.49
Case 79: 416.75
Case 80: No solution
Case 81: 27.84
Case 82: 945.63
Case 83: 769.94
Case 84: 1604.60
Case 85: 0.00
Case 86: 1067.45
Case 87: 545.62
Case 88: 879.19
Case 89: 1621.95
Case 90: 0.00
Case 91: 1271.65
Case 92: 0.00
Case 93: 746.44
Case 94: 1077.55
Case 95: No solution
Case 96: 827.78
Case 97: 462.17
Case 98: No solution
Case 99: 1983.98
Case 100: 197.14
``````
Check input and AC output for thousands of problems on uDebug!

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

### Re: 1612 - Guess

Try solving it without using floating point.
Check input and AC output for thousands of problems on uDebug!