v 0. Pasted by slipstak2 as cpp at 2011-11-01 07:50:16 MSK and set expiration to never.

Paste will expire never.

  1. // Очно-заочный кружок
  2. // Занятие №9. Олимпиадные задачи
  3. // Задача C. Результаты олимпиады
  4. // ibelyaev: 31Oct2011
  5. // http://cppalgo.blogspot.com/2011/04/blog-post.html
  6.  
  7. #include <iostream>
  8. #include <cstdio>
  9. #include <algorithm>
  10. #include <string>
  11. #include <string.h>
  12. #include <cmath>
  13. #include <queue>
  14. #include <vector>
  15. #include <map>
  16. #include <stdlib.h> // for exit(0)
  17. #include <stack>
  18. #include <list>
  19. #include <ctime>
  20. #include <set>
  21.  
  22. using namespace std;
  23. struct task {
  24.     int min_tests;
  25.     int all_tests;
  26. };
  27. vector<task> tasks;
  28. int n;
  29. struct task_result {
  30.     int points;
  31.     int attempts;
  32.     int time;
  33.     task_result(): points(0), attempts(0), time(0){}
  34. };
  35. vector<task_result> res;
  36. void check(int time, int num, int tests) {
  37.     int points = 0;
  38.     if (tasks[num].all_tests == tests)
  39.         points = 2;
  40.     else if (tasks[num].min_tests <= tests)
  41.         points = 1;
  42.  
  43.     if (res[num].points < points) {
  44.         res[num].points = points;
  45.         res[num].time = res[num].attempts * 20 + time;
  46.     }
  47.  
  48.     res[num].attempts++;
  49. }
  50. int main()
  51. {
  52.     freopen("input.txt","r",stdin);
  53.     freopen("output.txt","w",stdout);
  54.  
  55.     scanf("%d", &n);
  56.     tasks.resize(n);
  57.     res.resize(n);
  58.     for (int i=0;i<n;++i)
  59.         scanf("%d", &tasks[i].all_tests);
  60.     for (int i=0;i<n;++i)
  61.         scanf("%d", &tasks[i].min_tests);
  62.     int m,time,num,tests;
  63.     scanf("%d", &m);
  64.     for (int i=0;i<m;++i) {
  65.         scanf("%d %d %d", &time, &num, &tests);
  66.         if (tests == -1) continue;
  67.         check(time,num-1,tests);
  68.     }
  69.  
  70.     int points = 0, penalty = 0;
  71.     for (int i=0;i<n;++i) {
  72.         points += res[i].points;
  73.         penalty += res[i].time;
  74.     }
  75.     printf("%d %d", points, penalty);
  76.  
  77.     return 0;
  78. }


Editing is locked.