YEZAELP

PROG-2033: POI

Jun 19th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. struct DATA{
  4.     int score=0,solve=0,id=0;
  5. };
  6.  
  7. bool compare(DATA a,DATA b){
  8.     if(a.score == b.score){
  9.         if(a.solve == b.solve) return a.id < b.id;
  10.         else return a.solve > b.solve;
  11.     }
  12.     else return a.score > b.score;
  13. }
  14. int point[2001];
  15. int main(){
  16.  
  17.     int n,t,p;
  18.     scanf("%d%d%d",&n,&t,&p);
  19.  
  20.     DATA data[n+1];
  21.     vector <int> k[n+1];
  22.  
  23.     for(int i=1;i<=n;i++){
  24.         data[i].id=i;
  25.         for(int j=1;j<=t;j++){
  26.             int x;
  27.             scanf("%d",&x);
  28.             if(x==1) {
  29.                 data[i].solve++;
  30.                 k[i].push_back(j);
  31.             }
  32.             else point[j]++;
  33.         }
  34.     }
  35.  
  36.     for(int i=1;i<=n;i++){
  37.         for(auto j:k[i]){
  38.             data[i].score+=point[j];
  39.         }
  40.     }
  41.  
  42.     sort(data+1,data+n+1,compare);
  43.  
  44.     for(int i=1;i<=n;i++){
  45.         if(data[i].id==p) {
  46.             printf("%d %d",data[i].score,i);
  47.             return 0;
  48.         }
  49.     }
  50.  
  51.     return 0;
  52. }
Add Comment
Please, Sign In to add comment