# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1205364 | AbdulazizHany | Rotating Lines (APIO25_rotate) | C++20 | 0 ms | 0 KiB |
#include "rotate.h"
#include <bits/stdc++.h>
using namespace std;
void energy(int n, vector<int> v)
{
if(n==2){
if(v[0]<v[1]){
if(v[1]-v[0]>=25000)rotate({0},(v[1]-v[0])-25000);
else{
rotate({1},((25000+v[0])-v[1]));
}
}else{
if (v[0] - v[1] >= 25000)
rotate({1}, (v[0] - v[1])-25000);
else
{
rotate({0}, ((25000 + v[1]) - v[0]));
}
}
return;
}
vector<pair<int, int>> arr;
for (int i = 0; i < v.size(); i++)
arr.push_back({v[i], i});
sort(arr.begin(), arr.end());
for (int i = 0; i < (n+1) / 2; i++)
{
int x = arr[i].first + 25000;
x %= 50000;
int y = arr[i + ((n+1) / 2)].first, need;
if (y <= x)
need = x - y;
else
{
need=50000-(y-x)
}
rotate({arr[i + ((n+1) / 2)].second}, need);
}
}