Advertisement
mihaimarcel21

Campionat2

Mar 27th, 2021
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream fin("campionat.in");
  4. ofstream fout("campionat.out");
  5. int T, N, D, scor[1001], A[1001][1001];
  6. int meci[1001], vmax, scormax[1001], sol[1001], da;
  7. int main()
  8. {
  9.     int x, y, i, j;
  10.     fin>>T;
  11.     fin>>N;
  12.     for(i=1; i<=N; i++)
  13.         fin>>scor[i];
  14.     fin>>D;
  15.     for(i=1; i<=D; i++)
  16.     {
  17.         fin>>x>>y;
  18.         A[x][y]=A[y][x]=1;
  19.     }
  20.     for(i=1; i<=N; ++i)
  21.         for(j=1; j<=N; ++j)
  22.             meci[i]+=A[i][j];
  23.     if(T==1)
  24.     {
  25.         for(i=1; i<=N; ++i)
  26.             if(scor[i]+meci[i] > vmax)
  27.                 vmax=scor[i]+meci[i];
  28.         for(i=1; i<=N; ++i)
  29.             if(vmax==scor[i]+meci[i])
  30.                 fout<<i<<" ";
  31.         return 0;
  32.     }
  33.     for(i=1; i<=N; ++i)
  34.     {
  35.         scormax[i]=scor[i]+3*meci[i];
  36.         int ok=0;
  37.         for(j=1; j<=N; ++j)
  38.             if(j!=i)
  39.             {
  40.                 vmax=scor[j]+3*meci[j]-3*A[i][j];
  41.                 if(scormax[i]>vmax)
  42.                     ok++;
  43.             }
  44.         if(ok==N-1)
  45.             fout<<i<<" ", da=1;
  46.     }
  47.     if(!da)
  48.         fout<<0;
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement