# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
589711 | Mohammed_Atalah | Wiring (IOI17_wiring) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Template path: /home/mohammed/.config/sublime-text-3/Packages/User
#include "wiring.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// typedef
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// Marcos
#define int long long
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
// use \n insted of endl
long long min_total_length(std::vector<int> r, std::vector<int> b) {
int szr = r.size();
int szb = b.size();
reverse(b.begin(), b.end());
int total = 0;
for (int i = 0 ; i < szr - 1; i++) {
total += abs(r[i] - r[i + 1]) * (i + 1);
}
for (int i = 0 ; i < szb - 1; i++) {
total += abs(b[i] - b[i + 1]) * (i + 1);
}
total += abs(r[szr - 1] - b[szr - 1]) * max(szr, szb);
return total;
}
// int32_t main() {
// fast;
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
// // Just another problem (-_-)
// int t;
// cin >> t;
// // t = 1
// while (t--) {
// main_solve();
// }
// }