Submission #148933

# Submission time Handle Problem Language Result Execution time Memory
148933 2019-09-01T05:25:21 Z rkm0959(#3623, jun6873, babo) Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
360 ms 17644 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  

#define L long long

using namespace std;
using namespace __gnu_pbds;  

int n;

typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;  

ordered_set st;


L SelectCross(int K, vector<int>I, vector<int> O){
	L ret=0;	
	n=I.size();
	int i;
	vector<pair<int,int> >point;
	for(i=0;i<n;i++)
	{
		point.push_back(make_pair(O[i],I[i]));
	}
	sort(point.begin(),point.end(),[](pair<int,int>a, pair<int,int>b){
		return a.second<b.second;
	});
	for(i=n-1;i>=0;i--)
	{
		st.insert(point[i]);
		if(st.size()>=K)
		{
			L a=point[i].second;
			L b=st.find_by_order(st.size()-K)->first;
			//printf("%lld %lld %lld %lld\n",point[i].first,point[i].second,a,b);
			ret=max(ret,2*a*b-a*a);
		}
		else
		{
			//printf("%lld %lld\n",point[i].first,point[i].second);
		}
	}
	return ret;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:35:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(st.size()>=K)
      ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 7 ms 512 KB Output is correct
5 Correct 17 ms 1408 KB Output is correct
6 Correct 307 ms 17632 KB Output is correct
7 Correct 315 ms 17632 KB Output is correct
8 Correct 312 ms 17640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 7 ms 512 KB Output is correct
5 Correct 17 ms 1408 KB Output is correct
6 Correct 307 ms 17632 KB Output is correct
7 Correct 315 ms 17632 KB Output is correct
8 Correct 312 ms 17640 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 17 ms 1408 KB Output is correct
13 Correct 131 ms 9196 KB Output is correct
14 Correct 311 ms 17640 KB Output is correct
15 Correct 360 ms 17508 KB Output is correct
16 Correct 350 ms 17632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 7 ms 512 KB Output is correct
5 Correct 17 ms 1408 KB Output is correct
6 Correct 307 ms 17632 KB Output is correct
7 Correct 315 ms 17632 KB Output is correct
8 Correct 312 ms 17640 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 17 ms 1408 KB Output is correct
13 Correct 131 ms 9196 KB Output is correct
14 Correct 311 ms 17640 KB Output is correct
15 Correct 360 ms 17508 KB Output is correct
16 Correct 350 ms 17632 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 18 ms 1536 KB Output is correct
20 Correct 134 ms 9056 KB Output is correct
21 Correct 213 ms 13928 KB Output is correct
22 Correct 284 ms 17640 KB Output is correct
23 Correct 298 ms 17636 KB Output is correct
24 Correct 311 ms 17644 KB Output is correct
25 Correct 323 ms 17636 KB Output is correct
26 Correct 275 ms 17632 KB Output is correct