Submission #1353598

#TimeUsernameProblemLanguageResultExecution timeMemory
1353598tsetsenbilegRotating Lines (APIO25_rotate)C++20
16 / 100
28 ms2788 KiB
#include "rotate.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;
using ld = long double;
using pr = pair<int, int>;
const int MOD = 1e9+7, MAXA = 1e6, MAX = 50000;

void energy(int n, vector<int> v){
    vector<pr> a, b;
    for (int i = 0; i < n; i++) a.pb({v[i], i});
    sort(a.begin(), a.end(), [](const pr& x, const pr& y) {
        return min(x.first, MAX - x.first) < min(y.first, MAX - y.first);
    });
    // for (int i = n/2; i < n; i++) b.pb(a[i]);
    // a.resize(n/2);
    // sort(b.begin(), b.end(), [](const pr& x, const pr& y) {
    //     return abs(25000 - x.first) < abs(25000 - y.first);
    // });
    for (int i = 0; i < n/2; i++) {
        rotate({a[i].second}, MAX - a[i].first);
        int diff = 25000 - a[n-1 - i].first;
        if (diff < 0) diff += MAX;
        rotate({a[n-1 - i].second}, diff);
    }
    if (n % 2 == 1) {
        rotate({a[n/2].second}, MAX - a[n/2].first);
    }
    // return (n / 2 * (n+1) / 2) * 25000;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...