Advertisement
Guest User

Untitled

a guest
Apr 18th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.65 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5.  
  6. /**
  7.  * Auto-generated code below aims at helping you parse
  8.  * the standard input according to the problem statement.
  9.  **/
  10.  
  11. int main()
  12. {
  13.     int M;
  14.     scanf("%d", &M); fgetc(stdin);
  15.    
  16.     int T[100][15] = {{0}};
  17.     float TC = 0;
  18.     float TC2 = 0;
  19.    
  20.     fprintf(stderr, "M=%d\n", M);
  21.    
  22.     int d = 0;
  23.     for (int i = 0; i < M; i++) {
  24.         char LINE[45];
  25.         fgets(LINE, 45, stdin);
  26.        
  27.         char *p = LINE;
  28.         int k = 0;
  29.         int n;
  30.         int s = 0;
  31.         while (sscanf(p, "%d %n" , &T[i - d][k], &n) == 1) {
  32.             p += n;
  33.             s += T[i - d][k];
  34.             k += 1;
  35.         }
  36.        
  37.         if (s == 0)
  38.             d += 1;
  39.     }
  40.    
  41.     M -= d;
  42.    
  43.     for (int k = 0; k < M; k += 1) {
  44.         fprintf(stderr, "T[%d] = [", k);
  45.         for (int j = 0; j < 15; j += 1) {
  46.             fprintf(stderr, "%d%s", T[k][j], j == 14 ? "" : ", ");
  47.         }
  48.         fprintf(stderr, "]\n", k);
  49.     }
  50.  
  51.    
  52.    
  53.     for (int k = 0; k < M; k += 1) {
  54.         float s = 0;
  55.         for (int j = 0; j < 15; j += 1) {
  56.             s += T[k][j];
  57.         }
  58.         TC += 10 + (s - 40) / 7;
  59.     }
  60.    
  61.     int k = 0;
  62.     float s = 0;
  63.     int m = M * 15;
  64.     if (m % 2 == 1)
  65.         m -= 1;
  66.        
  67.     while (k < m) {
  68.         s += T[k / 15][k % 15];
  69.         if (k % 2 == 0)
  70.             s += 5;
  71.         k += 1;
  72.     }
  73.    
  74.     fprintf(stderr, "total = %f\n", TC / M);
  75.    
  76.    
  77.     printf("%0.1f\n", TC / M);
  78.     if (TC / M >= 5 && TC / M <= 30)
  79.         printf("%.1f\n", s / m * 2);
  80.  
  81.     return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement