Submission #792221

# Submission time Handle Problem Language Result Execution time Memory
792221 2023-07-24T17:49:23 Z cig32 Med (COCI22_med) C++17
50 / 50
77 ms 348 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
  int u = uniform_int_distribution<int>(x, y)(rng); return u;
}
int bm(int b, int p) {
  if(p==0) return 1 % MOD;
  int r = bm(b, p >> 1);
  if(p&1) return (((r*r) % MOD) * b) % MOD;
  return (r*r) % MOD;
}
int inv(int b) { 
  return bm(b, MOD-2);
}
int fastlog(int x) {
  return (x == 0 ? -1 : 64 - __builtin_clzll(x) - 1);
}
void printcase(int i) { cout << "Case #" << i << ": "; }
bool cmp(pair<string, int> a, pair<string, int> b) {
  return (a.second == b.second ? a.first < b.first : a.second > b.second);
}
void solve(int tc) {
  
  int n;
  cin >> n;
  pair<string, int> p[n+1];
  string bruh[n+1];
  for(int i=1; i<=n; i++) {
    cin >> p[i].first;
    bruh[i] = p[i].first;
    p[i].second = 0;
    for(int j=0; j<5; j++) {
      int x;
      cin >> x;
      p[i].second += x;
    }
  }
  for(int i=1; i<=n; i++) {
    for(int j=1; j<=n; j++) {
      if(p[j].first == bruh[i]) p[j].second += 500;
    }
    sort(p+1, p+1+n, cmp);
    for(int j=1; j<=n; j++) {
      if(p[j].first == bruh[i]) cout << j << " ";
    }
    for(int j=1; j<=n; j++) {
      if(p[j].first == bruh[i]) p[j].second -= 500;
      else p[j].second += 500;
    }
    sort(p+1, p+1+n, cmp);
    for(int j=1; j<=n; j++) {
      if(p[j].first == bruh[i]) cout << j << "\n";
    }
    for(int j=1; j<=n; j++) {
      if(p[j].first != bruh[i]) p[j].second -= 500;
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; //cin >> t;
  for(int i=1; i<=t; i++) solve(i);
}
// 勿忘初衷
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 39 ms 348 KB Output is correct
6 Correct 69 ms 340 KB Output is correct
7 Correct 43 ms 340 KB Output is correct
8 Correct 77 ms 340 KB Output is correct
9 Correct 20 ms 348 KB Output is correct