QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#224905#7617. SpectacleSolitaryDream#WA 104ms12456kbC++171.4kb2023-10-23 17:19:372023-10-23 17:19:38

Judging History

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

  • [2023-10-23 17:19:38]
  • 评测
  • 测评结果:WA
  • 用时:104ms
  • 内存:12456kb
  • [2023-10-23 17:19:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
inline int Calc(pii a) {
    return (a.second - a.first + 2) / 2;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<pii> dif;
    for (int i = 0; i + 1 < n; ++i) {
        dif.push_back({a[i + 1] - a[i], i});
    }
    sort(dif.begin(), dif.end());
    map<int, int> mp;
    int cur_pair = 0;
    vector<int> ans(n / 2);
    for (auto [d, x] : dif) {
        int last_pair = cur_pair;
        auto [it, _] = mp.insert({x, x}); 
        ++cur_pair;
        if (it != mp.begin() && prev(it)->second == x - 1) {
            cur_pair -= Calc(*it);
            cur_pair -= Calc(*prev(it));
            --it;
            it->second = x;
            cur_pair += Calc(*it);
            mp.erase(next(it));
        }
        if (next(it) != mp.end() && next(it)->first == x + 1) {
            ++it;
            cur_pair -= Calc(*it);
            cur_pair -= Calc(*prev(it));
            --it;
            it->second = x;
            cur_pair += Calc(*it);
            mp.erase(next(it));
        }
        for (int i = last_pair; i < cur_pair; ++i) ans[i] = d;
    }
    for (auto x : ans) cout << x << ' ';
    cout << endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
100 13 20 14 10 105

output:

1 5 6 

result:

ok single line: '1 5 6 '

Test #2:

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

input:

2
1 1000000000000000000

output:

999999999999999999 

result:

ok single line: '999999999999999999 '

Test #3:

score: -100
Wrong Answer
time: 104ms
memory: 12456kb

input:

200000
30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 ...

result:

wrong answer 1st lines differ - expected: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...99 9999 10000 10000 10000 10000', found: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '