QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#224903#7617. SpectacleSolitaryDream#WA 0ms4120kbC++171.3kb2023-10-23 17:18:092023-10-23 17:18:09

Judging History

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

  • [2023-10-23 17:18:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4120kb
  • [2023-10-23 17:18:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
inline int Calc(pii a) {
    return (a.second - a.first + 2) / 2;
}
int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &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) printf("%d ", x);
    puts("");
    return 0;
}

详细

Test #1:

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

input:

6
100 13 20 14 10 105

output:

1 5 6 

result:

ok single line: '1 5 6 '

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 4120kb

input:

2
1 1000000000000000000

output:

1486618625 

result:

wrong answer 1st lines differ - expected: '999999999999999999', found: '1486618625 '