QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124939#5653. Library gameHongzy#WA 2ms3456kbC++141.4kb2023-07-15 19:43:122023-07-15 19:43:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 19:43:13]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3456kb
  • [2023-07-15 19:43:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int gi() {
	int res = 0, w = 1;
	char ch = getchar();
	while (ch != '-' && !isdigit(ch)) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
	return res * w;
}
#define fi first
#define se second
#define pii pair<int, int>
using LL = long long;
using db = long double;
const LL INF = 1e18;
const int Mod = 998244353;
const int MAX_N = 5005;
int N, M, a[MAX_N];
void solve() {
	N = gi(), M = gi();
	for (int i = 1; i <= N; i++) a[i] = gi();
	sort(a + 1, a + N + 1);
	int pos = 0;
	for (int i = N; i >= 1; i--)
		if (M / a[i] < N - i) { pos = a[i]; break; }
	if (pos == 0) {
		cout << "Alessia" << endl;
		set<pii> S; S.emplace(M, 1);
		for (int i = N; i >= 1; i--) {
			auto p = *S.rbegin(); S.erase(p);
			cout << a[i] << " " << p.se << endl;
			int y = gi(); S.emplace(y - p.se, p.se);
			int t = p.fi - (y - p.se) - 1;
			if (t > 0) S.emplace(t, y + 1);
		}
	} else {
		cout << "Bernardo" << endl;
		for (int i = 1; i <= N; i++) {
			int y = gi(), a = gi();
			if (y >= pos) cout << (a + pos - 1) / pos * pos << endl;
			else cout << a << endl;
		}
	}
}
int main () {
#ifndef ONLINE_JUDGE
    freopen("cpp.in", "r", stdin);
	//freopen("cpp.out", "w", stdout);
#endif
	int T = 1; //T = gi();
	while (T--) {
		solve();
	}
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3456kb

input:

5 14
3 7 2 3 10
7
14
9
2
11

output:

Alessia
10 1
7 8
3 8
3 1
2 10

result:

ok Contestant won the game

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3456kb

input:

4 10
4 1 6 4
4
8
8
5

output:

Alessia
6 1
4 5
4 5
1 5

result:

wrong answer Judge won the game