Submission #1126085

#TimeUsernameProblemLanguageResultExecution timeMemory
1126085joylintpNile (IOI24_nile)C++20
67 / 100
2093 ms4736 KiB
#include<bits/stdc++.h> using namespace std; vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) { int N = W.size(); long long ansBase = 0; vector<pair<int, int>> art; for (int i = 0; i < N; i++) { art.push_back(make_pair(W[i], A[i] - B[i])); ansBase += B[i]; } sort(art.begin(), art.end()); vector<long long> R; for (int D : E) { long long ans = ansBase; for (int i = 0; i < N; ) { int j = i + 1; while (j < N && art[j].first - art[j - 1].first <= D) j++; if ((j - i) & 1) { int mn = art[i].second; for (int x = 0; i + x < j; x++) if (~x & 1 || art[i + x + 1].first - art[i + x - 1].first <= D) mn = min(mn, art[i + x].second); ans += mn; } i = j; } R.push_back(ans); } 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...