QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#315185 | #7617. Spectacle | thomas_li# | RE | 1ms | 3648kb | C++17 | 1.3kb | 2024-01-27 02:43:01 | 2024-01-27 02:43:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back
#define FS first
#define SD second
#define ary(k) array<int,k>
template<class A, class B> void cmx(A& x, B y){ x = max<A>(x,y); }
template<class A, class B> void cmn(A& x, B y){ x = min<A>(x,y); }
typedef pair<int,int> pii;
typedef vector<int> vi;
signed main(){
cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
int n; cin >> n;
vi a(n); for(int& v : a) cin >> v;
sort(all(a));
vector<pii> vals;
rep(i,0,n-1){
vals.PB({a[i+1]-a[i],i});
}
sort(all(vals));
vi in(n-1);
set<pii> ins; int cur = 0;
vector<pii> chk;
for(auto[k,i]:vals){
int l = i, r = i;
in[i] = 1;
if(l > 0 && in[l-1]){
auto itr = --lower_bound(all(ins),pii{i,-1});
assert(itr->SD == l-1);
l = itr->FS;
cur -= (itr->SD-itr->FS+2)/2;
ins.erase(itr);
}
if(r+1 < n-1 && in[r+1]){
auto itr = lower_bound(all(ins),pii{i,-1});
assert(itr->SD== r+1);
r = itr->SD;
cur -= (itr->SD-itr->FS+2)/2;
ins.erase(itr);
}
ins.insert({l,r});
cur += (r-l+1+1)/2;
chk.PB({cur,k});
}
rep(i,1,n/2+1){
auto itr = lower_bound(all(chk),pii{i,-1});
cout << itr->second << " \n"[i==n/2];
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
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: 3648kb
input:
2 1 1000000000000000000
output:
999999999999999999
result:
ok single line: '999999999999999999'
Test #3:
score: -100
Runtime Error
input:
200000 30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...