Submission #229272

#TimeUsernameProblemLanguageResultExecution timeMemory
229272534351Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
130 ms12648 KiB
#include "cross.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define SZ(x) ((int) (x).size()) #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; const int MAXN = 200013; const int INF = 1e9 + 7; const ll LLINF = 3e18; int N, K; pll arr[MAXN]; priority_queue<ll, vector<ll>, greater<ll> > pq; ll ans; ll SelectCross(int kk, vi inner, vi outer) { N = SZ(inner); K = kk; //2ab - b^2 FOR(i, 0, N) { arr[i] = {inner[i], outer[i]}; } sort(arr, arr + N, greater<pii>()); // FOR(i, 0, N) // { // cerr << arr[i].fi << ',' << arr[i].se << endl; // } FOR(i, 0, K) { pq.push(arr[i].se); } ckmax(ans, arr[K - 1].fi * (2 * pq.top() - arr[K - 1].fi)); //delete the smallest, query the smallest. FOR(i, K, N) { pq.push(arr[i].se); pq.pop(); ckmax(ans, arr[i].fi * (2 * pq.top() - arr[i].fi)); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...