Submission #151250

#TimeUsernameProblemLanguageResultExecution timeMemory
151250dongwon0427Crosses on the Grid (FXCUP4_cross)C++17
0 / 100
2 ms376 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef long long ll; long long SelectCross(int k, std::vector<int> I, std::vector<int> O) { int n = I.size(); vector<pii> v; for(int i=0;i<n;i++) { v.push_back(pii(I[i], O[i])); } sort(v.begin(), v.end()); vector<pii> w; for(int i=0;i<n;i++) { while(!w.empty() && w.back().second <= v[i].second) w.pop_back(); w.push_back(v[i]); } n = w.size(); k = min(k, n); ll ret = 0; for(int i=0;i+k-1<n;i++) { ret = max(ret, (ll)w[i].first * w[i+k-1].second); } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...