# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58269 | alenam0161 | Candies (JOI18_candies) | C++17 | 737 ms | 46480 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 200000+7;
int a[N];
int l[N],r[N],p[N];
long long val[N];
int sz[N];
int fnd(int v){
return v==p[v] ? v:p[v]=fnd(p[v]);
}
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<=n;++i)scanf("%d",&a[i]);
for(int i=1;i<=n;++i){
r[i]=l[i]=p[i]=i;
val[i]=a[i];
sz[i]=1;
}
multiset<pair<long long,int> > st;
for(int i=1;i<=n;++i){
st.insert({a[i],i});
}
int hw=(n+1)/2;
long long ans=0;
p[n+1]=n+1;
p[0]=0;
while(st.size()>0){
auto it=st.end();it--;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |