제출 #1122555

#제출 시각아이디문제언어결과실행 시간메모리
1122555Mousa_Aboubaker나일강 (IOI24_nile)C++17
32 / 100
161 ms17788 KiB
#include "nile.h" #include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 1; vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) { vector<int> w = W, a = A, b = B, e = E; int n = w.size(), q = e.size(); sort(w.begin(), w.end()); map<int, vector<int>, greater<int>> mp1; map<int, int> res; for(int i = 1; i < n; i++) mp1[w[i] - w[i - 1]].push_back(i); map<int, int> dp; dp[inf] = n + (n & 1); set<pair<int, int>> lst; lst.insert({0, n - 1}); int lst_idx = inf; for(auto [f, s]: mp1) { for(auto i: s) { auto it = prev(lst.upper_bound({i, -1})); auto [ff, ss] = *it; lst.erase(it); lst.insert({ff, i - 1}); lst.insert({i, ss}); int len1 = ss - ff + 1; int len2 = i - ff; int len3 = ss - i + 1; if(!(len1 & 1)) if(len2 & 1) dp[f] += 2; } //cout << f << '\n'; //for(auto [f, s]: lst) //{ // cout << f << ' ' << s << '\n'; //} dp[f] += dp[lst_idx]; lst_idx = f; } vector<long long> fin(q); for(int i = 0; i < q; i++) { fin[i] = dp.upper_bound(e[i]) -> second; } return fin; }
#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...