Submission #722431

#TimeUsernameProblemLanguageResultExecution timeMemory
722431grossly_overconfidentRoad Closures (APIO21_roads)C++17
5 / 100
48 ms3768 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' //#define int long long //#define INT_MAX LONG_LONG_MAX vector<long long> minimum_closure_costs(int n, vector<int> u, vector<int> v, vector<int> w){ vector<long long> out(n); bool good = false; for (int i = 0; i < n; ++i){ if (u[i] != 0){ good = true; break; } } if (good){ long long op1 = 0, op2 = 0, total = 0; for (int i = 0; i < n; i += 2){ op1 += w[i]; } for (int i = 1; i < n; i += 2){ op2 += w[i]; } for (int i = 0; i < n; ++i){ total += w[i]; } out[0] = total; out[1] = min(op1, op2); return out; } sort(w.begin(), w.end()); int j = 0; for (int i = n - 2; i >= 0; --i){ out[i] = out[i + 1] + w[j]; j++; } return out; }
#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...