Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <cstdio>
  4.  
  5. #include <cstring>
  6.  
  7. #include <cstdlib>
  8.  
  9. #include <cmath>
  10.  
  11. #include <algorithm>
  12.  
  13. #include <vector>
  14.  
  15. #include <map>
  16.  
  17. using namespace std;
  18.  
  19.  
  20.  
  21. #define MAX 17000
  22.  
  23. #define eps 1e-7
  24.  
  25.  
  26.  
  27. struct con{
  28.  
  29. double a, b, c;
  30.  
  31. double score[10];
  32.  
  33. }cc[MAX];
  34.  
  35.  
  36.  
  37. struct rank{
  38.  
  39. int i, r;
  40.  
  41. }rr[MAX];
  42.  
  43.  
  44.  
  45. void score(int i){
  46.  
  47. cc[i].score[0] = cc[i].a + cc[i].b + cc[i].c;
  48.  
  49. cc[i].score[1] = cc[i].a + cc[i].b;
  50.  
  51. cc[i].score[2] = cc[i].b + cc[i].c;
  52.  
  53. cc[i].score[3] = cc[i].a + cc[i].c;
  54.  
  55. cc[i].score[4] = cc[i].a;
  56.  
  57. cc[i].score[5] = cc[i].b;
  58.  
  59. cc[i].score[6] = cc[i].c;
  60.  
  61. cc[i].score[7] = 0.0;
  62.  
  63. }
  64.  
  65.  
  66.  
  67. int main()
  68.  
  69. {
  70.  
  71. int i, j, k, n, t = 1;
  72.  
  73. double hh;
  74.  
  75. while(scanf("%d", &n)==1) {
  76.  
  77. if(!n) return 0;
  78.  
  79. for(i = 1; i <= n; i++) {
  80.  
  81. scanf("%lf %lf %lf", &cc[i].a, &cc[i].b, &cc[i].c);
  82.  
  83. score(i);
  84.  
  85. sort(cc[i].score, cc[i].score+8, greater < double > () );
  86.  
  87. }
  88.  
  89. for(i = 1; i <= n; i++){
  90.  
  91. scanf("%d", &rr[i].i);
  92.  
  93. rr[i].r = i;
  94.  
  95. }
  96.  
  97. hh = cc[rr[1].i].score[0];
  98.  
  99. k = 0;
  100.  
  101. for(i = 2; i <= n; i++){
  102.  
  103. for(j = 0; j < 8; j++){
  104.  
  105. if(cc[rr[i].i].score[j]+eps < hh){
  106.  
  107. hh = cc[rr[i].i].score[j];
  108.  
  109. break;
  110.  
  111. }
  112.  
  113. else if(cc[rr[i].i].score[j] - hh < eps){
  114.  
  115. if(rr[i].i < rr[i-1].i) continue;
  116.  
  117. break;
  118.  
  119. }
  120.  
  121. }
  122.  
  123. if(j > 7) k = 1;
  124.  
  125. if(k) break;
  126.  
  127. }
  128.  
  129. if(k) printf("Case %d: No solution\n", t);
  130.  
  131. else printf("Case %d: %.2lf\n", t, hh+eps);
  132.  
  133. t++;
  134.  
  135. }
  136.  
  137. // system("pause");
  138.  
  139. return 0;
  140.  
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement