QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#721725 | #6770. Ants | 333zhan | WA | 146ms | 34468kb | C++20 | 1.7kb | 2024-11-07 16:41:40 | 2024-11-07 16:41:40 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
constexpr int L = 1E9 + 1;
void solve () {
int n, x, y;
cin >> n >> x >> y;
vector <int> a (n), d (n);
for (int i = 0; i < n; i ++) {
cin >> a[i];
}
for (int i = 0; i < n; i ++) {
cin >> d[i];
}
int t = min (x, y) / n;
int ans = t * L * 2;
x -= t * n;
y -= t * n;
vector <pair <int, int>> b (n);
for (int i = 0; i < n; i ++) {
b[i].first = d[i] == 0 ? a[i] : (L - a[i]);
b[i].second = d[i];
}
sort (b.begin (), b.end ());
int s1 = 0, s2 = 0;
ans += b.back ().first;
for (auto [c, o] : b) {
if (o == 0) {
if (x != 0) {
x --;
s1 ++;
}
} else {
if (y != 0) {
y --;
s2 ++;
}
}
}
// cerr << s1 << " " << s2 << " " << x << " " << y << '\n';
while (s1 || s2) {
ans += L;
swap (s1, s2);
if (x) {
int t = min (x, s1);
x -= t;
if (x) {
s1 -= t;
} else {
s1 = 0;
}
} else {
s1 = 0;
}
if (y) {
int t = min (y, s2);
y -= t;
if (y) {
s2 -= t;
} else {
s2 = 0;
}
} else {
s2 = 0;
}
}
cout << ans << '\n';
}
signed main () {
ios::sync_with_stdio (false);
cin.tie (nullptr);
int T = 1;
// cin >> T;
while (T --) {
solve ();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
input:
2 2 4 2 3 0 1
output:
4000000001
result:
ok single line: '4000000001'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
1 1000000000 1000000000 500000000 0
output:
2000000002500000000
result:
ok single line: '2000000002500000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
1 1000000000 500000000 500000000 1
output:
1000000001500000001
result:
ok single line: '1000000001500000001'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1 500000000 1000000000 500000000 0
output:
1000000001500000000
result:
ok single line: '1000000001500000000'
Test #5:
score: -100
Wrong Answer
time: 146ms
memory: 34468kb
input:
999963 1000000000 1000000000 516 793 2609 2721 3010 3378 4494 6294 7719 9298 9582 10021 10255 13552 16357 16771 16864 18824 19006 19162 19583 22099 22970 23637 25760 26962 29349 31140 34093 34398 35622 35765 35868 35899 36213 37137 38062 43181 43361 44347 46328 48145 48188 49187 50303 50873 52999 53...
output:
2002000001486
result:
wrong answer 1st lines differ - expected: '2001074431727', found: '2002000001486'