This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |