Submission #149622

# Submission time Handle Problem Language Result Execution time Memory
149622 2019-09-01T06:51:22 Z Solo Leveling (#3786, wzy) Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
228 ms 19116 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<long long,long long>
#define F first
#define S second
typedef long long ll;
multiset<ll> Sx;

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	vector<pii> v(I.size());
	for(int i = 0 ; i < I.size() ; i ++){
		v.push_back(pii(O[i] , I[i]));
	}
	sort(v.rbegin() , v.rend());
	ll ans = 0;
	for(int i = 0 ; i < I.size() ; i ++){
		if(Sx.size() == K-1){
			ll uu = v[i].second;
			if(Sx.size()){
				auto u = Sx.begin();
				uu = *u;
				uu = min(uu , v[i].second);
			}

			ans = max(ans , v[i].first * v[i].first - (v[i].first - uu)*(v[i].first - uu));
		}
		Sx.insert(v[i].second);
		while(Sx.size() >= K){
			auto u = Sx.begin();
			ll X = *u;
			Sx.erase(Sx.find(X));
		}
	}
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:12:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < I.size() ; i ++){
                  ~~^~~~~~~~~~
cross.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < I.size() ; i ++){
                  ~~^~~~~~~~~~
cross.cpp:18:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(Sx.size() == K-1){
      ~~~~~~~~~~^~~~~~
cross.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(Sx.size() >= K){
         ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 14 ms 1024 KB Output is correct
6 Correct 137 ms 9964 KB Output is correct
7 Correct 139 ms 9960 KB Output is correct
8 Correct 138 ms 9964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 14 ms 1024 KB Output is correct
6 Correct 137 ms 9964 KB Output is correct
7 Correct 139 ms 9960 KB Output is correct
8 Correct 138 ms 9964 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 384 KB Output is correct
12 Correct 14 ms 1024 KB Output is correct
13 Correct 75 ms 5360 KB Output is correct
14 Correct 134 ms 9956 KB Output is correct
15 Correct 139 ms 9960 KB Output is correct
16 Correct 137 ms 9984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 14 ms 1024 KB Output is correct
6 Correct 137 ms 9964 KB Output is correct
7 Correct 139 ms 9960 KB Output is correct
8 Correct 138 ms 9964 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 384 KB Output is correct
12 Correct 14 ms 1024 KB Output is correct
13 Correct 75 ms 5360 KB Output is correct
14 Correct 134 ms 9956 KB Output is correct
15 Correct 139 ms 9960 KB Output is correct
16 Correct 137 ms 9984 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 248 KB Output is correct
19 Correct 17 ms 1584 KB Output is correct
20 Correct 78 ms 5680 KB Output is correct
21 Correct 109 ms 8000 KB Output is correct
22 Correct 138 ms 9964 KB Output is correct
23 Correct 141 ms 9880 KB Output is correct
24 Correct 160 ms 11308 KB Output is correct
25 Correct 201 ms 15916 KB Output is correct
26 Correct 228 ms 19116 KB Output is correct