Advertisement
lmarioza

Untitled

Sep 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int v, p, t; scanf("%d %d %d", &v, &p, &t);
  5.     for (; t != 0; scanf("%d %d %d", &v, &p, &t)) {
  6.         int tempos[p];
  7.         for (int i = 0; i < p; i++) {
  8.             int d; scanf("%d", &d);
  9.             tempos[i] = (d*3.6)/v;
  10.         }
  11.         //printf("tempos corretos: "); for (int i = 0; i < p; i++) printf("%lf ", tempos[i]); printf("\n");
  12.         int clas[t];
  13.         for (int i = 0; i < t; i++) clas[i] = i + 1;
  14.         int pontos[t];
  15.         for (int i = 0; i < t; i++) pontos[i] = 0;
  16.         for (int i = 0; i < t; i++) {
  17.             for (int j = 0; j < p; j++) {
  18.                     int k; scanf("%d", &k);
  19.                     if (k < tempos[j]) {
  20.                         if (2 * (tempos[j] - k) > 1200) pontos[i] += 1200;
  21.                         else pontos[i] += 2 * (tempos[j] - k);
  22.                     }
  23.                     else {
  24.                         if (k - tempos[j] > 1200) pontos[i] += 1200;
  25.                         else pontos[i] += k - tempos[j];
  26.                     }
  27.             }
  28.             //printf("%d: %lf\n", i, pontos[i]);
  29.         }
  30.         for (int i = 0; i < t; i++) {
  31.             for (int j = 0; j < t - 1 - i; j++) {
  32.                 if (pontos[j] > pontos [j + 1]){
  33.  
  34.                     double temp = pontos[j+1];
  35.                     pontos[j+1] = pontos[j];
  36.                     pontos[j] = temp;
  37.  
  38.                     temp = clas[j+1];
  39.                     clas[j+1] = clas[j];
  40.                     clas[j] = temp;
  41.                 }
  42.             }
  43.         }
  44.         for (int i = 0; i < t; i++) printf(i == 0 ? "%d" : " %d", clas[i]); printf("\n");
  45.     }
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement