Submission #1195748

#TimeUsernameProblemLanguageResultExecution timeMemory
1195748lrnnzBoxes with souvenirs (IOI15_boxes)C++20
0 / 100
0 ms396 KiB
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include "boxes.h" using namespace std; #define all(a) (a).begin(), (a).end() #define sz(a) (int)(a).size() #define ll long long #define ld long double #define ui uint64_t #define cont(set, element) ((set).find(element) != (set).end()) /********* DEBUG *********/ template <typename T> void outvec(const vector<T>& Z){ for (const T& x : Z) cout << x << ' '; cout << "\n"; } void printVariable(const any& var) { if (!var.has_value()) { cout << "null"; return; } if (var.type() == typeid(int)) { cout << any_cast<int>(var); } else if (var.type() == typeid(double)) { cout << any_cast<double>(var); } else if (var.type() == typeid(float)) { cout << any_cast<float>(var); } else if (var.type() == typeid(char)) { cout << any_cast<char>(var); } else if (var.type() == typeid(bool)) { cout << (any_cast<bool>(var) ? "true" : "false"); } else if (var.type() == typeid(string)) { cout << any_cast<string>(var); } else if (var.type() == typeid(const char*)) { cout << any_cast<const char*>(var); } else if (var.type() == typeid(long long)) { cout << any_cast<long long>(var); } else { cout << "[unknown type]"; } } template<typename... Args> void outval(Args... args) { vector<any> variables = {args...}; for (size_t i = 0; i < variables.size(); ++i) { printVariable(variables[i]); if (i != variables.size() - 1) { cout << " "; } } cout << "\n"; } #define nl "\n" #define sp << " " << /********* DEBUG *********/ const ll MOD = 1000000007; const ll inf = 1e18; const ll mxN = 1000005; // just try every possible split ll delivery(int N, int K, int L, int p[]) { if (L == 1) return 0; vector<ll> left(N+1), right(N+1); for (int i = 0; i < N; i++){ left[i] = p[i] <= L/2 ? p[i] * 2 : L; if (i >= K) left[i] += left[i-K]; } //outvec(left); for (int i = N-1; i >= 0; i--){ right[i] = p[i] <= L/2 ? L : (L-p[i])*2; if (p[i] == 0) right[i] = right[i+1]; else if (i <= N-K-1) right[i] += right[i+K]; } //outvec(right); ll ans = min(left[0] + right[1], right[N-1] + left[N-2]); for (int i = 1; i < N-1; i++) ans = min(ans, left[i] + right[i+1]); return ans; }
#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...