(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.

제출 #1111927

#제출 시각아이디문제언어결과실행 시간메모리
1111927SalihSahin모임들 (IOI18_meetings)C++14
0 / 100
2 ms336 KiB
#include <bits/stdc++.h> #define pb push_back //#define int long long using namespace std; #include "meetings.h" const long long inf = 1e17; //#include "meetings.h" vector<vector<int> > mx; int M, K; int query(int l, int r){ int ind = 0; while((1 << (ind + 1)) <= (r - l + 1)){ ind++; } return max(mx[l][ind], mx[r - (1 << ind) + 1][ind]); } std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R) { int n = H.size(); vector<array<int, 3> > segments; int cnt = 0; for(int i = 0; i < n; i++){ if(i == n-1 || H[i] == 2){ if(H[i] == 1){ segments.pb({i - cnt, i, cnt + 1}); } else if(cnt > 0){ segments.pb({i - cnt, i - 1, cnt}); } cnt = 0; } else cnt++; } M = segments.size(); K = 18; mx.resize(M); for(int i = 0; i < M; i++){ mx[i].resize(K); mx[i][0] = segments[i][2]; } for(int i = 1; i < K; i++){ for(int j = 0; j < M; j++){ mx[j][i] = max(mx[j][i-1], mx[min(M-1, j + (1 << (i - 1)))][i-1]); } } int Q = L.size(); vector<long long> C(Q); for (int j = 0; j < Q; ++j) { long long ans = 2 * (R[j] - L[j] + 1); int l = 0, r = M; while(l < r){ int m = (l + r)/2; if(segments[m][1] >= L[j]) r = m; else l = m + 1; } int sol = l; l = 0, r = M; while(l < r){ int m = (l + r + 1)/2; if(segments[m][0] <= R[j]) l = m; else r = m - 1; } int sag = l; int cik = 0; if(segments[sol][0] < L[j]){ cik = max(cik, segments[sol][1] - L[j] + 1); sol++; } if(segments[sag][1] > R[j]){ cik = max(cik, R[j] - segments[sag][0] + 1); sag--; } if(sol <= sag){ cik = max(cik, query(sol, sag)); } ans -= cik; C[j] = ans; } return C; }
#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...