QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767571#1441. Special GamezhaohaikunWA 2ms3796kbC++231.9kb2024-11-20 21:17:372024-11-20 21:17:37

Judging History

This is the latest submission verdict.

  • [2024-11-20 21:17:37]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3796kb
  • [2024-11-20 21:17:37]
  • 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) {
		// 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 {
		if (a.front() > b.back()) {
			if (flag) ans += i;
			break;
		}
		ans += !flag;
		int pos = 0, ta = 0, tb = 0;
		F(j, 0, SZ(a)) {
			while (pos <= SZ(b) && b[pos] < a[j]) pos++;
			if (pos <= SZ(b)) {
				if (b[pos] - a[j] >= tb - ta) ta = a[j], tb = b[pos];
			}
		}
		assert(ta);
		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--;
		}
		swap(a, b);
		flag ^= true;
		// }
	}
	cout << ans;
	return 0;
}
/* why?
*/

详细

Test #1:

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

input:

3
1 2 5
3 4 6

output:

1

result:

ok "1"

Test #2:

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

input:

2
4 3
1 2

output:

2

result:

ok "2"

Test #3:

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

input:

1
1
2

output:

0

result:

ok "0"

Test #4:

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

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: 0
Accepted
time: 0ms
memory: 3716kb

input:

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

output:

3

result:

ok "3"

Test #6:

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

input:

4
2 8 1 7
5 6 3 4

output:

2

result:

ok "2"

Test #7:

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

input:

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

output:

4

result:

ok "4"

Test #8:

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

input:

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

output:

6

result:

ok "6"

Test #9:

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

input:

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

output:

5

result:

ok "5"

Test #10:

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

input:

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

output:

6

result:

ok "6"

Test #11:

score: -100
Wrong Answer
time: 2ms
memory: 3504kb

input:

821
37 1527 1243 1615 582 1085 1168 524 333 479 130 719 450 946 940 251 908 1458 729 267 1474 623 625 1002 1407 1297 1585 809 32 712 891 943 1331 82 648 655 1295 515 459 982 1486 691 896 1626 1105 903 1255 1593 1444 494 370 537 258 1196 862 1440 539 928 424 1080 1500 1330 317 906 288 727 735 580 811...

output:

409

result:

wrong answer 1st words differ - expected: '406', found: '409'