(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #944974

#TimeUsernameProblemLanguageResultExecution timeMemory
944974gelastropodMeetings (IOI18_meetings)C++14
0 / 100
12 ms2008 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; #define int long long vector<long long> minimum_costs(vector<signed> H, vector<signed> L, vector<signed> R) { int N = H.size(), Q = L.size(); stack<int> stk; vector<int> f2s(N, 0), b2s(N, 0); for (int i = 0; i < N; i++) { if (H[i] == 2) { f2s[i] = i; while (!stk.empty()) { f2s[stk.top()] = i; stk.pop(); } } else { stk.push(i); } } while (!stk.empty()) { f2s[stk.top()] = -1; stk.pop(); } for (int i = N - 1; i >= 0; i--) { if (H[i] == 2) { b2s[i] = i; while (!stk.empty()) { b2s[stk.top()] = i; stk.pop(); } } else { stk.push(i); } } while (!stk.empty()) { b2s[stk.top()] = -1; stk.pop(); } vector<int> ans; for (int i = 0; i < Q; i++) { if (f2s[L[i]] == -1 || f2s[L[i]] > R[i]) ans.push_back(R[i] + 1 - L[i]); else ans.push_back((R[i] + 1 - L[i]) * 2 - max(f2s[L[i]] - L[i], R[i] - b2s[R[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...