Submission #149363

#TimeUsernameProblemLanguageResultExecution timeMemory
149363Showing Hands (#200)Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
269 ms14440 KiB
#include "cross.h" #include<bits/stdc++.h> #define sz(x) ((int)x.size()) #define pb push_back #define ii pair<int,int> #define st first #define nd second #define ll long long #define N 200005 #define inf 1000000005 #define MOD 1000000007 using namespace std; long long SelectCross(int K, std::vector<int> I, std::vector<int> O) { ll ans=0; multiset<int> s; s.insert(inf); int n=sz(I); vector<ii> a(n); for(int i=0;i<n;i++) { a[i]={I[i],O[i]}; } sort(a.begin(),a.end(),[](ii x,ii y) { if(x.st==y.st) return x.nd>y.nd; return x.st<y.st; }); for(int i=n-1;i>=0;i--) { if(sz(s)==K) ans=max(ans,2ll*(min(*s.begin(),a[i].nd))*a[i].st-(ll)a[i].st*a[i].st); s.insert(a[i].nd); while(sz(s)>K) s.erase(s.begin()); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...