Submission #936013

# Submission time Handle Problem Language Result Execution time Memory
936013 2024-03-01T01:14:29 Z Regulus Med (COCI22_med) C++17
50 / 50
117 ms 508 KB
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define bug(x) cerr << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
//#define TEST
const int N = 505;
struct Fuck { string s; int sum=0; } a[N], b[N];

inline bool cmp(Fuck a, Fuck b)
{
    return (a.sum != b.sum)?a.sum > b.sum : a.s < b.s;
}

inline int find(string &s)
{
    int cur = 1;
    while (cur <= 500)
    {
        if (b[cur].s == s) return cur;
        ++cur;
    }
    assert(0); return -1;
}

int main(void)
{ IO
    int n, i;

    cin >> n;
    for (i=1; i <= n; ++i)
    {
        int x; cin >> a[i].s;
        for (int j=0; j < 5; ++j)
            cin >> x, a[i].sum += x;
    }

    for (i=1; i <= n; ++i)
    {
        for (int j=1; j <= n; ++j) b[j] = a[j];
        b[i].sum += 500;
        sort(b+1, b+n+1, cmp);
        int it = find(a[i].s);
        //for (int j=1; j <= n; ++j) bug(b[j].s), bug(b[j].sum), endl;

        for (int j=1; j <= n; ++j) b[j] = a[j], b[j].sum += 500;
        b[i].sum -= 500;
        sort(b+1, b+n+1, cmp);
        int it2 = find(a[i].s);
        //for (int j=1; j <= n; ++j) bug(b[j].s), bug(b[j].sum), endl;

        cout << it << ' ' << it2 << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 56 ms 348 KB Output is correct
6 Correct 109 ms 504 KB Output is correct
7 Correct 62 ms 360 KB Output is correct
8 Correct 117 ms 508 KB Output is correct
9 Correct 31 ms 360 KB Output is correct