#include "rotate.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
vector<int> pos;
const int HALF=50000;
const int ACUT=25000;
void energy(signed n, std::vector<signed> v){
ordered_set os;
for (int i = 0; i < sz(v); i++) os.insert({v[i],i});
while (sz(os)>1)
{
pair<int,int> p=*os.find_by_order(0);
int md=os.order_of_key({p.first+ACUT,-1});
pair<int,int> pa;
if(md>sz(os)/2) pa=*os.find_by_order(md-1);
else pa=*os.find_by_order(md);
int df=(p.first+ACUT-pa.first);
if(df<0) df+=HALF;
rotate({(signed)pa.second},(signed)df);
os.erase(pa);
os.erase(p);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |