Submission #149561

# Submission time Handle Problem Language Result Execution time Memory
149561 2019-09-01T06:44:40 Z Solo Leveling (#3786, wzy) Crosses on the Grid (FXCUP4_cross) C++17
0 / 100
5 ms 384 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 - 2LL*(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 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -