답안 #884230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884230 2023-12-06T21:12:37 Z tsumondai Med (COCI22_med) C++14
10 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)
#define __TIME  (1.0 * clock() / CLOCKS_PER_SEC)

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 500 + 5;

const int oo = 1e9, mod = 1e9 + 7;

int n;
ii ans[N];
ii coms[N];

map<int, string> dick;

void process() {
	cin >> n;
	foru(i, 1, n) {
		string s; int sum = 0;
		cin >> s;
		foru(i, 1, 5) {
			int x; cin >> x; sum += x;
		}
		//cout << sum << '\n';
		coms[i] = {sum, i};
		dick[i]=s;
	}

	sort(coms + 1, coms + 1 + n, greater<ii>());

	foru(i, 1, n) {
		int cur = i;
		int l = i, r = i;
		while (abs(coms[cur].fi - coms[i].fi) < 500 && cur>=1) cur--;
		while (abs(coms[cur].fi - coms[i].fi) == 500 && cur>=1 && dick[coms[i].se] <= dick[coms[cur].se]) cur--;
		l = cur + 1;
		cur = i;
		while (abs(coms[cur].fi - coms[i].fi) < 500 && cur<=n) cur++;
		while (abs(coms[cur].fi - coms[i].fi) == 500 && cur<=n && dick[coms[i].se] >= dick[coms[cur].se]) cur--;
		r = cur - 1;
		ans[coms[i].se] = {l, r};
	}

	foru(i, 1, n) cout << ans[i].fi << ' ' << ans[i].se << '\n';

	return;
}

signed main() {
	cin.tie(0)->sync_with_stdio(false);
	//freopen(".inp", "r", stdin);
	//freopen(".out", "w", stdout);
	process();
	cerr << "Time elapsed: " << __TIME << " s.\n";
	return 0;
}

// dont stop
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -