| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1365533 | gay | Rotating Lines (APIO25_rotate) | C++20 | 0 ms | 836 KiB |
#include <vector>
#include <algorithm>
#include <numeric>
void rotate(std::vector<int> t, int x);
void energy(int n, std::vector<int> v) {
std::vector<int> p(n);
std::iota(p.begin(), p.end(), 0);
std::sort(p.begin(), p.end(), [&](int a, int b) {
return v[a] < v[b];
});
int m = n / 2;
int target_base = v[p[m]];
int target_alt = (target_base + 25000) % 50000;
for (int i = 0; i < m; ++i) {
int id = p[i];
int current_v = v[id];
int diff = (target_alt - current_v + 50000) % 50000;
if (diff != 0) {
rotate({id}, diff);
v[id] = target_alt;
}
}
for (int i = n - 1; i >= m; --i) {
int id = p[i];
int current_v = v[id];
int diff = (target_base - current_v + 50000) % 50000;
if (diff != 0) {
rotate({id}, diff);
v[id] = target_base;
}
}
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
