QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#124890 | #5150. Alternating Algorithm | jzh# | WA | 1ms | 3496kb | C++14 | 610b | 2023-07-15 17:30:08 | 2023-07-15 17:30:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
n++;
vector<pll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin(), a.end());
ll ans = 0;
for (int i = 0; i < n; i++) {
ll cur = abs(i - a[i].second);
if (a[i].second < i) {
cur += (a[i].second % 2);
} else {
cur += (a[i].second % 2 == 0);
}
ans = max(ans, cur);
}
cout << ans << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3496kb
input:
3 8 13 4 10
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3400kb
input:
5 13 12 14 10 14 12
output:
3
result:
ok single line: '3'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3392kb
input:
2 2 2 1
output:
3
result:
ok single line: '3'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3424kb
input:
1 300172042 474444146
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'