Submission #148608

# Submission time Handle Problem Language Result Execution time Memory
148608 2019-09-01T04:45:54 Z CHT를 사랑하는 모임(#3587, moonrabbit2, Retro3014, gs18115) Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
134 ms 8860 KB
#include "cross.h"
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;
typedef tuple<int,int,int,int> TP;
typedef vector<vector<ll>> mat;
const int N=2e5+5;
const ll mod=1e9+7;
int n,k;
ll ans;
pll p[N];
priority_queue<ll,vector<ll>,greater<ll>> pq;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	n=I.size(); k=K;
	for(int i=1;i<=n;i++){
		p[i]=pll(I[i-1],O[i-1]);
	}
	sort(p+1,p+1+n);
	for(int i=n;i>=1;i--){
		if(pq.size()==k-1){
			ll v;
			if(k!=1) v=min(pq.top(),p[i].se);
			else v=p[i].se;
			ans=max(ans,p[i].fi*(2LL*v-p[i].fi));
			//cout<<p[i].fi<<" : "<<pq.top()<<" "<<" "<<v<<ans<<endl;
		}
		pq.push(p[i].se);
		if(pq.size()==k) pq.pop();
	}
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(pq.size()==k-1){
      ~~~~~~~~~^~~~~
cross.cpp:34:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(pq.size()==k) pq.pop();
      ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 128 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 11 ms 768 KB Output is correct
6 Correct 113 ms 6628 KB Output is correct
7 Correct 110 ms 6760 KB Output is correct
8 Correct 118 ms 6756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 128 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 11 ms 768 KB Output is correct
6 Correct 113 ms 6628 KB Output is correct
7 Correct 110 ms 6760 KB Output is correct
8 Correct 118 ms 6756 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 13 ms 768 KB Output is correct
13 Correct 66 ms 3696 KB Output is correct
14 Correct 123 ms 6764 KB Output is correct
15 Correct 120 ms 6764 KB Output is correct
16 Correct 111 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 128 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 11 ms 768 KB Output is correct
6 Correct 113 ms 6628 KB Output is correct
7 Correct 110 ms 6760 KB Output is correct
8 Correct 118 ms 6756 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 13 ms 768 KB Output is correct
13 Correct 66 ms 3696 KB Output is correct
14 Correct 123 ms 6764 KB Output is correct
15 Correct 120 ms 6764 KB Output is correct
16 Correct 111 ms 6612 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 7 ms 384 KB Output is correct
19 Correct 14 ms 1024 KB Output is correct
20 Correct 63 ms 3824 KB Output is correct
21 Correct 96 ms 5504 KB Output is correct
22 Correct 119 ms 6744 KB Output is correct
23 Correct 126 ms 6764 KB Output is correct
24 Correct 130 ms 7140 KB Output is correct
25 Correct 134 ms 8808 KB Output is correct
26 Correct 124 ms 8860 KB Output is correct