QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404754#7617. Spectacleucup-team3215#WA 120ms14360kbC++201.6kb2024-05-04 17:08:082024-05-04 17:08:10

Judging History

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

  • [2024-05-04 17:08:10]
  • 评测
  • 测评结果:WA
  • 用时:120ms
  • 内存:14360kb
  • [2024-05-04 17:08:08]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pl = pair<ll, ll>;

void solve() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (auto &i: a)cin >> i;
    sort(a.begin(), a.end());
    vector<pl> b;
    for (ll i = 0; i + 1 < n; ++i) {
        b.push_back({a[i + 1] - a[i], i});
    }
    sort(b.begin(), b.end());
    set<pl> s;
    ll val = 0;
    ll i = 0;
    auto eval = [&](pl x) {
        return (x.second - x.first + 1 + 1) / 2;
    };
    for (ll need = 1; need <= n / 2; ++need) {
        while (val != need) {
            pl range = {b[i].second, b[i].second};
            {
                auto it = s.upper_bound({range.first, -1});
                if (it != s.begin() && it->second + 1 == b[i].second) {
                    --it;
                    range.first = min(range.first, it->first);
                    range.second = max(range.second, it->second);
                    val -= eval(*it);
                    s.erase(it);
                }
            }
            {
                auto it = s.upper_bound({range.first, -1});
                if (it != s.end() && it->first - 1 == b[i].second) {
                    range.first = min(range.first, it->first);
                    range.second = max(range.second, it->second);
                    val -= eval(*it);
                    s.erase(it);
                }
            }
            val += eval(range);
            s.insert(range);
            ++i;
        }
        cout << b[i - 1].first << " ";
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(false);
    int t = 1;
//    cin >> t;
    while (t--)solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3496kb

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: 3540kb

input:

2
1 1000000000000000000

output:

999999999999999999 

result:

ok single line: '999999999999999999 '

Test #3:

score: -100
Wrong Answer
time: 120ms
memory: 14360kb

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 ... 6934 6934 6934 6934 6934 6934 '