Submission #1110510

#TimeUsernameProblemLanguageResultExecution timeMemory
1110510VMaksimoski008Nile (IOI24_nile)C++17
67 / 100
2059 ms7996 KiB
#include "nile.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) { int Q = (int)E.size(), n = (int)A.size(); vector<long long> R(Q, 0); vector<array<int, 3> > a(n+1); for(int i=1; i<=n; i++) a[i] = { W[i-1], A[i-1], B[i-1] }; sort(a.begin()+1, a.end()); for(int t=0; t<Q; t++) { vector<ll> dp(n+1, 1e18); dp[0] = 0; for(int i=1; i<=n; i++) { dp[i] = dp[i-1] + a[i][1]; if(i > 1 && a[i][0] - a[i-1][0] <= E[t]) dp[i] = min(dp[i], dp[i-2] + a[i-1][2] + a[i][2]); if(i > 2 && a[i][0] - a[i-2][0] <= E[t]) dp[i] = min(dp[i], dp[i-3] + a[i-2][2] + a[i-1][1] + a[i][2]); } R[t] = dp[n]; } 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...