QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#222921#7617. Spectacleucup-team1264#TL 0ms3448kbC++201.0kb2023-10-21 19:42:482023-10-21 19:42:48

Judging History

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

  • [2023-10-21 19:42:48]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3448kb
  • [2023-10-21 19:42:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;

constexpr i64 INF = 1e18 + 1145;

void solve() {
    int n;
    cin >> n;
    vector<i64> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ranges::sort(a);
    vector<i64> ans(n + 1);
    function<void(int, int, i64, i64)> solve = [&](int l, int r, i64 vl,
                                                   i64 vr) {
        if (vl == vr) {
            for (int i = l; i <= r; i++)
                ans[i] = vl;
            return;
        }

        if (l > r) return;
        int c = 0;
        i64 vm = (vl + vr) / 2;
        for (int i = 0; i < n - 1; i++) {
            if (a[i + 1] - a[i] <= vm) c++, i++;
        }
        solve(l, c, vl, vm), solve(c + 1, r, vm + 1, vr);
    };
    solve(1, n / 2, 0, INF);
    for (int i = 1; i <= n / 2; i++)
        cout << ans[i] << " ";
    cout << "\n";
}

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

詳細信息

Test #1:

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

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

input:

2
1 1000000000000000000

output:

999999999999999999 

result:

ok single line: '999999999999999999 '

Test #3:

score: -100
Time Limit Exceeded

input:

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

output:


result: