QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124890#5150. Alternating Algorithmjzh#WA 1ms3496kbC++14610b2023-07-15 17:30:082023-07-15 17:30:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 17:30:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3496kb
  • [2023-07-15 17:30:08]
  • 提交

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'