Submission #940244

#TimeUsernameProblemLanguageResultExecution timeMemory
940244SundavarFinancial Report (JOI21_financial)C++14
0 / 100
180 ms20216 KiB
#include <bits/stdc++.h> using namespace std; struct dat{ int price, len, id; bool operator < (dat a) const{ return a.price > price; } }; int main(){ int n, d; cin>>n>>d; vector<int> used(n, -1), price(n); set<dat> best; best.insert({0,0, -1}); multiset<int> el; for(int i = 0; i < n; i++){ cin>>price[i]; if(i > d){ el.erase(el.find(price[i-d-1])); while(best.size() > 1){ auto it = next(best.begin()); if(it->price < *el.begin()) best.erase(it); else break; } } auto it = best.lower_bound({price[i], -1, -1}), p = prev(it); el.insert({price[i]}); if(it != best.end() && it->price == price[i]) continue; if(it != best.end() && it->len == p->len+1) best.erase(it); best.insert({price[i], p->len+1, i}); } cout << prev(best.end())->len << "\n"; }
#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...