QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#402844 | #7689. Flipping Cards | ucup-team3215# | WA | 1ms | 3732kb | C++20 | 1.0kb | 2024-05-01 16:31:14 | 2024-05-01 16:31:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
constexpr int INF = 1e9 + 7;
int main() {
cin.tie(0)->sync_with_stdio(false);
int n;
cin >> n;
vector<pi> a(n);
for (auto &[x, y]: a)cin >> x >> y;
int l = 0, r = INF;
int need = (n + 1) / 2;
while (r - l > 1) {
int mid = (r + l) / 2;
int bal = 0;
vector<int> v(n, 0);
for (int i = 0; i < n; ++i) {
if (a[i].first >= mid) {
++bal;
--v[i];
} else {
--bal;
++v[i];
}
if (a[i].second >= mid) {
++v[i];
} else {
--v[i];
}
}
int mx = 0, mn = 0, cur = 0;
for (int i = 0; i < n; ++i) {
cur += v[i];
mx = max(mx, cur + mn);
mn = min(mn, cur);
}
bal += mx;
if (bal >= 0) {
l = mid;
} else r = mid;
}
cout << l << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3608kb
input:
5 3 6 5 2 4 7 6 4 2 8
output:
6
result:
ok 1 number(s): "6"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
1 2 1
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
1 212055293 384338286
output:
384338286
result:
ok 1 number(s): "384338286"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3732kb
input:
99 749159996 323524232 125448341 365892333 481980673 143665393 394405973 44741918 687549448 513811513 287088118 385131171 11865696 666468353 449920567 373650719 671547289 116780561 41003675 671513243 351534153 507850962 374160874 985661954 222519431 600582098 987220654 704142246 856147059 37783620 1...
output:
507346252
result:
wrong answer 1st numbers differ - expected: '528957505', found: '507346252'