QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#221641#7617. Spectacleucup-team1516#WA 0ms3884kbC++203.2kb2023-10-21 14:05:102023-10-21 14:05:11

Judging History

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

  • [2023-10-21 14:05:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3884kb
  • [2023-10-21 14:05:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define int128 __int128_t
#define pii128 pair<int128,int128>
const int inf = 1 << 30;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
const db EPS = 1e-10;
const db pi = acos(-1);
template<class T> bool chmin(T& x, T y){
    if(x > y) {
        x = y;
        return true;
    } else return false;
}
template<class T> bool chmax(T& x, T y){
    if(x < y) {
        x = y;
        return true;
    } else return false;
}

// overload macro
#define CAT( A, B ) A ## B
#define SELECT( NAME, NUM ) CAT( NAME, NUM )

#define GET_COUNT( _1, _2, _3, _4, _5, _6 /* ad nauseam */, COUNT, ... ) COUNT
#define VA_SIZE( ... ) GET_COUNT( __VA_ARGS__, 6, 5, 4, 3, 2, 1 )

#define VA_SELECT( NAME, ... ) SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__)

// rep(overload)
#define rep( ... ) VA_SELECT(rep, __VA_ARGS__)
#define rep2(i, n) for (int i = 0; i < int(n); i++)
#define rep3(i, a, b) for (int i = a; i < int(b); i++)
#define rep4(i, a, b, c) for (int i = a; i < int(b); i += c)

// repll(overload)
#define repll( ... ) VA_SELECT(repll, __VA_ARGS__)
#define repll2(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repll3(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define repll4(i, a, b, c) for (ll i = a; i < (ll)(b); i += c)

// rrep(overload)
#define rrep( ... ) VA_SELECT(rrep, __VA_ARGS__)    
#define rrep2(i, n) for (int i = n - 1; i >= 0; i--)
#define rrep3(i, a, b) for (int i = b - 1; i >= a; i--)
#define rrep4(i, a, b, c) for (int i = b - 1; i >= a; i -= c)

// rrepll(overload)
#define rrepll( ... ) VA_SELECT(rrepll, __VA_ARGS__)
#define rrepll2(i, n) for (ll i = (ll)(n) - 1; i >= 0ll; i--)
#define rrepll3(i, a, b) for (ll i = b - 1; i >= (ll)(a); i--)
#define rrepll4(i, a, b, c) for (ll i = b - 1; i >= (ll)(a); i -= c)

// for_earh
#define fore(e, v) for (auto&& e : v)

// vector
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int n;
int lr[200010];
int ans[200010];
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> n;
    vector<int> rs(n);
    rep (i, n) {
        cin >> rs[i];
        lr[i] = -1;
    }

    sort(all(rs));
    vector<pii> v;
    rep (i, n - 1) {
        v.emplace_back(rs[i + 1] - rs[i], i);
    }
    sort(all(v));

    int pre = 0, res = 0;
    rep (i, n - 1) {
        auto [val, p] = v[i];
        int l = p, r = p + 1;
        int seg = 1;
        if (lr[l] != -1) {
            res -= (l - lr[l] + 1) / 2;
            seg += l - lr[l];
            l = lr[l];
        }

        if (lr[r] != -1) {
            res -= (lr[r] - r + 1) / 2;
            seg += lr[r] - r;
            r = lr[r];
        }

        res += (seg + 1) / 2;
        lr[l] = r, lr[r] = l;

        rep (j, pre + 1, res + 1) {
            ans[j] = val;
        }
        pre = res;
    }

    rep (i, 1, n / 2 + 1) cout << ans[i] << " \n"[i == n / 2 + 1];
}

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: -100
Wrong Answer
time: 0ms
memory: 3884kb

input:

2
1 1000000000000000000

output:

2147483646 

result:

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