#include "cross.h"
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;
long long SelectCross(int k, std::vector<int> in, std::vector<int> out) {
# define int ll
int n = sz(in);
vector<pair<int,int>>vec;
for(int i = 0;i < n;i++) vec.pb(mp(in[i],out[i]));
int ans = 0;
sort(vec.rbegin(),vec.rend());
multiset<int>tr;
for(int i = 0;i < n;i++){
int inner = vec[i].first;
if(k == 1) ans = max(ans, 1ll * inner * 2LL * (1ll*vec[i].second - 1LL*inner));
else if(sz(tr) == k - 1){
ans = max(ans, 1ll * inner * (2ll * (min(*tr.begin(),vec[i].second)) - 1ll*inner));
}
tr.insert(vec[i].second);
if(sz(tr) >= k) tr.erase(tr.begin());
}
return ans;
}
Compilation message
cross.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
# pragma GCC optimization ("unroll-loops")
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |