Submission #1123668

#TimeUsernameProblemLanguageResultExecution timeMemory
1123668math_rabbit_1028Nile (IOI24_nile)C++20
67 / 100
2094 ms6332 KiB
#include "nile.h" using namespace std; typedef long long ll; typedef pair<ll, ll> pll; vector<pll> C; ll block(int st, int ed, int D) { //[st, ed) ll ret = 1e18; if ((ed-st)%2 == 0) return 0; for (int i = st; i < ed; i++) { // [st, i) + [i+1, ed) if ((i-st)%2 == 0) ret = min(ret, C[i].second); else if (C[i+1].first - C[i-1].first <= D) ret = min(ret, C[i].second); } return ret; } vector<ll> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) { int Q = (int)E.size(); int N = (int)W.size(); ll sum = 0; for (int i = 0; i < N; i++) sum += B[i]; vector<ll> R(Q, sum); for (int i = 0; i < N; i++) C.push_back({W[i], A[i]-B[i]}); sort(C.begin(), C.end()); for (int t = 0; t < Q; t++) { ll D = E[t]; int st = 0; while (st < N) { for (int i = st+1; i <= N; i++) { if (i == N || C[i].first - C[i-1].first > D) { R[t] += block(st, i, D); st = i; break; } } } } return R; }
#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...