QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369064#7617. SpectacleDelay_for_five_minutes#WA 1ms3844kbC++201.6kb2024-03-27 20:09:042024-03-27 20:09:14

Judging History

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

  • [2024-03-27 20:09:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3844kb
  • [2024-03-27 20:09:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n;
typedef long long ll;
ll r[200005];
vector<ll> a,b;
ll ans[100005];
void solve(const vector<ll>& v) {
    vector<int> p(v.size()) , siz(v.size()) , vis(v.size());
    for(int i = 0;i < p.size();i++) p[i] =i  , siz[i] = 1;
    auto Find = [&](int x,auto self)->int {
        if(p[x] == x) return x;
        return p[x] = self(p[x] , self) ;
    };
    vector<pair<ll,int> > v2;
    for(int i = 0;i < v.size();i++) v2.push_back({v[i] , i}) ;
    sort(v2.begin() , v2.end()) ;
    int ttl = 0;
    for(int i = 0;i < v2.size();i++) {
        int id = v2[i].second ;
        vis[id] = 1;
        if(id > 0 && vis[id - 1]) {
            int a = Find(id - 1 , Find) ;
            ttl -= (siz[a] + 1) / 2;
            p[a] = id ; siz[id] += siz[a] ;
        }
        if(id < v.size() - 1 && vis[id + 1]) {
            int a = Find(id + 1 , Find) ;
            ttl -= (siz[a] + 1) / 2;
            p[a] = id ; siz[id] += siz[a] ;
        }
        ttl += (siz[id] + 1) / 2;
        ans[ttl] = min(ans[ttl] , v2[i].first);
        // printf("T %d %lld : %lld\n",ttl,v2[i].first , ans[ttl]) ;
    }
    for(int i = n/2; i >= 1;i--) {
        ans[i] = min(ans[i] , ans[i + 1]) ;
    }
}
int main() {
    ios::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
    cin >> n;
    for(int i = 1;i <= n;i++) cin >> r[i];
    sort(r + 1, r + n + 1) ;
    for(int i = 2;i <= n;i++) {
        a.push_back(r[i] - r[i - 1]) ;
        // printf("%lld\n",r[i] - r[i - 1]) ;
    }
    for(int i = 1;i <= n/2 + 1;i++) ans[i] = 1e9;
    solve(a) ;
    for(int i = 1;i <= n/2;i++) cout << ans[i] <<' ' ;
}

详细

Test #1:

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

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

input:

2
1 1000000000000000000

output:

1000000000 

result:

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