Submission #632404

# Submission time Handle Problem Language Result Execution time Memory
632404 2022-08-19T23:25:56 Z Hacv16 Med (COCI22_med) C++17
50 / 50
97 ms 400 KB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAX = 615;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

#define pb push_back
#define sz(x) (int) x.size()
#define fr first
#define sc second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << ": " << "[ " << x << " ]\n"

int n;

struct bee{
    int s;
    string name;

    bee(int a = 0, string t = ""){
        s = a, name = t;
    }

    bool operator < (bee other){
        if(s != other.s) return s > other.s;
        return name < other.name;
    }

} v[MAX];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> v[i].name;

        for(int j = 0; j < 5; j++){
            int x; cin >> x;
            v[i].s += x;
        }
    }

    for(int i = 0; i < n; i++){
        vector<bee> mxv, mnv;

        for(int j = 0; j < n; j++){
            if(j == i) mxv.pb(bee(v[j].s + 500, v[j].name)), mnv.pb(bee(v[j].s - 500, v[j].name));
            else mxv.pb(v[j]), mnv.pb(v[j]); 
        }

        sort(all(mxv));
        sort(all(mnv));

        int mxp = 0, mnp = 0;

        for(int j = 0; j < n; j++)
            if(mxv[j].name == v[i].name) mxp = j + 1;

        for(int j = 0; j < n; j++)
            if(mnv[j].name == v[i].name) mnp = j + 1;

        cout << mxp << ' ' << mnp << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 44 ms 340 KB Output is correct
6 Correct 85 ms 396 KB Output is correct
7 Correct 53 ms 340 KB Output is correct
8 Correct 97 ms 400 KB Output is correct
9 Correct 33 ms 364 KB Output is correct