Submission #971791

#TimeUsernameProblemLanguageResultExecution timeMemory
971791fve5Meetings (IOI18_meetings)C++17
19 / 100
579 ms2264 KiB
#include <bits/stdc++.h> #include "meetings.h" using namespace std; vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { int N = H.size(); int Q = L.size(); vector<long long> ans(Q); if (Q <= 5000 && N <= 5000) { for (int i = 0; i < Q; i++) { vector<long long> cost_l(R[i] - L[i] + 2), cost_r(R[i] - L[i] + 2); stack<pair<int, int>> st; st.emplace(2e9, R[i] - L[i] + 1); for (int j = R[i] - L[i]; j >= 0; j--) { while (st.top().first <= H[j + L[i]]) st.pop(); cost_r[j] = cost_r[st.top().second] + (long long)H[j + L[i]] * (st.top().second - j); st.emplace(H[j + L[i]], j); } while (!st.empty()) st.pop(); st.emplace(2e9, 0); for (int j = 0; j <= R[i] - L[i]; j++) { while (st.top().first <= H[j + L[i]]) st.pop(); cost_l[j + 1] = cost_l[st.top().second] + (long long)H[j + L[i]] * (j + 1 - st.top().second); st.emplace(H[j + L[i]], j + 1); } ans[i] = 1e18; for (int j = 0; j <= R[i] - L[i]; j++) { ans[i] = min(ans[i], cost_l[j + 1] + cost_r[j] - H[j + L[i]]); } } } 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...