답안 #149051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149051 2019-09-01T05:38:53 Z Seishun Buta Yarou wa Yumemiru Shoujo no Yume wo Minai(#3781, zscoder, tmwilliamlin168) 십자가 놓기 (FXCUP4_cross) C++17
100 / 100
357 ms 19180 KB
#include "cross.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) 
{
	vector<ii> vec;
	int n=I.size();
	for(int i=0;i<n;i++)
	{
		vec.pb({O[i],I[i]});
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	ll ans = 0;
	pbds T;
	int timer=-1;
	for(int i=0;i<n;i++)
	{
		ll grid = vec[i].fi; 
		if(T.size()>=K-1)
		{
			ll vv = ll(1e18);
			if(K-2>=0) vv=-(*T.find_by_order(K-2)).fi;
			ll lowpt = min(vec[i].se, vv);
			ans = max(ans, grid*grid-(grid-lowpt)*(grid-lowpt));
		}
		T.insert({-vec[i].se,++timer});
	}
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:37:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(T.size()>=K-1)
      ~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 17 ms 1404 KB Output is correct
6 Correct 278 ms 19164 KB Output is correct
7 Correct 330 ms 19028 KB Output is correct
8 Correct 350 ms 19164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 17 ms 1404 KB Output is correct
6 Correct 278 ms 19164 KB Output is correct
7 Correct 330 ms 19028 KB Output is correct
8 Correct 350 ms 19164 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 7 ms 512 KB Output is correct
12 Correct 16 ms 1532 KB Output is correct
13 Correct 142 ms 9960 KB Output is correct
14 Correct 357 ms 19168 KB Output is correct
15 Correct 278 ms 19164 KB Output is correct
16 Correct 283 ms 19168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 17 ms 1404 KB Output is correct
6 Correct 278 ms 19164 KB Output is correct
7 Correct 330 ms 19028 KB Output is correct
8 Correct 350 ms 19164 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 7 ms 512 KB Output is correct
12 Correct 16 ms 1532 KB Output is correct
13 Correct 142 ms 9960 KB Output is correct
14 Correct 357 ms 19168 KB Output is correct
15 Correct 278 ms 19164 KB Output is correct
16 Correct 283 ms 19168 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 17 ms 1660 KB Output is correct
20 Correct 124 ms 9960 KB Output is correct
21 Correct 230 ms 15324 KB Output is correct
22 Correct 295 ms 19164 KB Output is correct
23 Correct 348 ms 19164 KB Output is correct
24 Correct 285 ms 19180 KB Output is correct
25 Correct 305 ms 19028 KB Output is correct
26 Correct 289 ms 19168 KB Output is correct