#include "cross.h"
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace placeholders;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T> inline void mini(T &l, T r){l = min(l, r);}
template <class T> inline void maxi(T &l, T r){l = max(l, r);}
template <class it> auto gr(it b, it e){
return vector<typename remove_reference<decltype(*b)>::type>(b, e);
}
template <class T> void _dbg(const char *sdbg, T h){cerr << sdbg << "=" << h << "\n";}
template <class T, class ...R> void _dbg(const char *sdbg, T h, R... a){
while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> v){
os << "["; for (auto x: v) os << x << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
return os << "(" << P.st << "," << P.nd << ")";
}
#ifndef ONLINE_JUDGE
#define eput(...) do{cerr << __LINE__;_dbg("\t| "#__VA_ARGS__, __VA_ARGS__);}while(0)
#else
#define eput(...) 218
#endif
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
typedef long long ll;
int N = I.size();
vector<pair<int, int>> a;
for (int i = 0; i < N; ++i)
a.emplace_back(I[i], O[i]);
sort(a.begin(), a.end(), greater<pair<int, int>>());
priority_queue<int, vector<int>, greater<int>> Q;
for (int i = 0; i < K; ++i)
Q.emplace(a[i].second);
ll ans = (ll)a[K - 1].first * (Q.top() * 2 - a[K - 1].first);
for (int i = K; i < N; ++i){
Q.emplace(a[i].second);
Q.pop();
ans = max(ans, (ll)a[i].first * (Q.top() * 2 - a[i].first));
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
114 ms |
5736 KB |
Output is correct |
7 |
Correct |
119 ms |
5736 KB |
Output is correct |
8 |
Correct |
117 ms |
5740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
114 ms |
5736 KB |
Output is correct |
7 |
Correct |
119 ms |
5736 KB |
Output is correct |
8 |
Correct |
117 ms |
5740 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
128 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
13 ms |
768 KB |
Output is correct |
13 |
Correct |
65 ms |
3184 KB |
Output is correct |
14 |
Correct |
117 ms |
5736 KB |
Output is correct |
15 |
Correct |
126 ms |
5732 KB |
Output is correct |
16 |
Correct |
122 ms |
5740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
114 ms |
5736 KB |
Output is correct |
7 |
Correct |
119 ms |
5736 KB |
Output is correct |
8 |
Correct |
117 ms |
5740 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
128 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
13 ms |
768 KB |
Output is correct |
13 |
Correct |
65 ms |
3184 KB |
Output is correct |
14 |
Correct |
117 ms |
5736 KB |
Output is correct |
15 |
Correct |
126 ms |
5732 KB |
Output is correct |
16 |
Correct |
122 ms |
5740 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
14 ms |
896 KB |
Output is correct |
20 |
Correct |
70 ms |
3184 KB |
Output is correct |
21 |
Correct |
102 ms |
5096 KB |
Output is correct |
22 |
Correct |
130 ms |
5744 KB |
Output is correct |
23 |
Correct |
127 ms |
5612 KB |
Output is correct |
24 |
Correct |
134 ms |
5736 KB |
Output is correct |
25 |
Correct |
128 ms |
6668 KB |
Output is correct |
26 |
Correct |
120 ms |
6880 KB |
Output is correct |