QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767508#1441. Special GamezhaohaikunWA 0ms3852kbC++232.1kb2024-11-20 21:09:462024-11-20 21:09:50

Judging History

This is the latest submission verdict.

  • [2024-11-20 21:09:50]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3852kb
  • [2024-11-20 21:09:46]
  • Submitted

answer

// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "\33[32m[" << __LINE__ << "]\33[m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T& x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T& x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = - f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= f;
}
const int N = 1010;
int n, ans;
bool flag = true;
signed main() {
	read(n);
	vector <int> a(n), b(n);
	for (int& i: a) read(i);
	for (int& i: b) read(i);
	sort(all(a));
	sort(all(b));
	DF(i, n, 1) {
		// debug << i << " " << flag << endl;
		// for (int j: a) cout << j << ' '; cout << '\n';
		// for (int j: b) cout << j << ' '; cout << '\n';
		if (a.back() > b.back()) {
			a.pop_back();
			int g = b.front();
			// debug << g << endl;
			for (int& j: a)
				if (j > g) j--;
			b.erase(b.begin());
			for (int& j: b) j--;
			ans += flag;
		} else {
			ans += !flag;
			int g = a.front();
			a.erase(a.begin());
			for (int& j: a) j--;
			for (int j: b) {
				if (j > g) {
					b.erase(find(all(b), j));
					break;
				}
			}
			for (int& j: b)
				if (j > g) j--;
			flag ^= true;
			swap(a, b);
			// int pos = 0, ta = 0, tb = 0;
			// F(j, 0, SZ(a)) {
			// 	while (b[pos] < a[j]) pos++;
			// 	if (b[pos] - a[j] > tb - ta) ta = a[j], tb = b[pos];
			// }
			// a.erase(find(all(a), ta));
			// b.erase(find(all(b), tb));
			// for (int& j: a) {
			// 	if (j > tb) j--;
			// 	if (j > ta) j--;
			// }
			// for (int& j: b) {
			// 	if (j > tb) j--;
			// 	if (j > ta) j--;
			// }
			// // debug << "@ " << ta << " " << tb << endl;
			// swap(a, b);
			// flag ^= true;
		}
	}
	cout << ans;
	return 0;
}
/* why?
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3604kb

input:

3
1 2 5
3 4 6

output:

1

result:

ok "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

2
4 3
1 2

output:

2

result:

ok "2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

1
1
2

output:

0

result:

ok "0"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

9
2 12 10 3 4 7 17 14 16
6 1 13 11 9 15 18 8 5

output:

5

result:

ok "5"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3852kb

input:

9
1 3 2 14 15 13 8 6 7
12 11 4 17 9 5 18 10 16

output:

4

result:

wrong answer 1st words differ - expected: '3', found: '4'