Submission #1306279

#TimeUsernameProblemLanguageResultExecution timeMemory
1306279stephitRotating Lines (APIO25_rotate)C++20
28 / 100
3095 ms2056 KiB
#include <bits/stdc++.h> using namespace std; const int N = 50000; #define fi first #define se second void rotate(std::vector<int> t, int x); long long calc(vector<int>& b) { long long res = 0; for (int i = 0; i < (int) b.size(); i++){ for (int j = i + 1; j < (int) b.size(); j++){ int d = abs(b[i] - b[j]); res += min(d, 50000 - d); } } return res; } void energy(int n, vector<int> v) { vector<pair<int, int>> a; for (int i = 0; i < n; i++) a.push_back({v[i], i}); sort(a.begin(), a.end()); vector<int> b; for (int i = 0; i < n; i++) b.push_back(a[i].fi); for (int i = 0; i < n; i++) { int cur = calc(b); int mx = 0, pos = -1; for (int j = 0; j < n; j++) { b[i] = b[j]; int ne = calc(b); if (ne > mx) mx = ne, pos = b[j]; b[i] = (b[j] + 25000) % N; ne = calc(b); if (ne > mx) mx = ne, pos = (b[j] + 25000) % N; } if (mx > cur) { b[i] = pos; } else b[i] = a[i].fi; } for (int i = 0; i < n; i++) { rotate({a[i].se}, - a[i].fi + b[i] + N); } }
#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...