QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226686#7617. SpectaclewtmWA 0ms3620kbC++14954b2023-10-26 13:42:002023-10-26 13:42:01

Judging History

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

  • [2023-10-26 13:42:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2023-10-26 13:42:00]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define pii pair <int, int>
#define fi first
#define se second

void solve() {
    int n;
    cin >> n;
    vector <int> a(n + 1), p(n);
    iota(p.begin(), p.end(), 0);
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    sort(a.begin() + 1, a.end());
    sort(p.begin() + 1, p.end(), [&](int i, int j) {
        return a[i + 1] - a[i] < a[j + 1] - a[j];
    });
    vector <int> vis(n + 1);
    int cnt = 0, now = 0;
    for (int i = 1; i <= n / 2; ++i) {
        while (cnt < i * 2) {
            ++now;
            if (!vis[p[now]]) ++cnt;
            if (!vis[p[now] + 1]) ++cnt;
            vis[p[now]] = vis[p[now] + 1] = 1;
        }
        cout << a[p[now] + 1] - a[p[now]] << ' ';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int T = 1;
    // cin >> T;
    while (T--) solve();

    return 0;
}
// 1 2 3

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

2
1 1000000000000000000

output:

2147483646 

result:

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