답안 #520150

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520150 2022-01-28T14:41:53 Z tost_one_love Sure Bet (CEOI17_sure) C++14
100 / 100
82 ms 5180 KB
#include <bits/stdc++.h>
  
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k ; i >= n ; --i)
#define YOSIK() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define toqta return 0
#define PERMUTE next_permutation
#define no cout<<"No"<<endl;
#define yes cout<<"Yes"<<endl;
#define a() a + 1, a + n + 1  
 
using namespace std;
 
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse,-fgcse-lm")
#pragma GCC optimize("-ftree-pre,-ftree-vrp")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
   
typedef long long ll;
typedef unsigned long long ull;
typedef string S;
typedef double ld;
typedef long double lld;
  
const int N = 1e6 + 17;
const int modd = 1e9 + 7;
const ll INF = 1e18 - 19;
const int P = 37;
const ll NN = 1e7 + 17;
const ld eps = 1e-19;
const double pi = 3.141592653589793238462643383279 ;
   
 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}
 
void pre (ll a) {
    cout << fixed << setprecision(a);
    return;
}
 
ll n;
double x[N], y[N], dpx[N], dpy[N];
double mx;
bool ok = 0;	
inline void Solution (/*Nuraly Serikbay*/) {
	cin >> n;
	for (int i = 1; i <= n; ++ i) {
		cin >> x[i] >> y[i];
	}
	sort (x + 1, x + n + 1, greater < double > ());
	sort (y + 1, y + n + 1, greater < double > ());
	for (ll i = 1; i <= n; ++ i){
		dpx[i] = x[i] + dpx[i - 1];
		dpy[i] = y[i] + dpy[i - 1];
	}
	ll i = 0, j = 0;
	double sum = 0, sum1 = 0;
	while  (i <= n and j <= n) {
		sum = dpx[i];
		sum1 = dpy[j];
		if (sum < sum1){
			i ++;
		}else
			j ++;
		sum = dpx[i];
		sum1 = dpy[j];
		mx = max (mx, min (sum - i - j, sum1 - i - j));
	}
	while (i <= n){
		i ++;
		sum = dpx[i];
		sum1 = dpy[j];
		mx = max (mx, min (sum - i - j, sum1 - i - j));
	}
	while (j <= n){
		j ++;
		sum = dpx[i];
		sum1 = dpy[j];
		mx = max (mx, min (sum - i - j, sum1 - i - j));
	}
	pre(4);
	cout << mx;	
	return;
}
 
 
int main () {
	YOSIK();
	Solution ();
	exit (0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 72 ms 4788 KB Output is correct
18 Correct 72 ms 4808 KB Output is correct
19 Correct 82 ms 4852 KB Output is correct
20 Correct 70 ms 4792 KB Output is correct
21 Correct 74 ms 5084 KB Output is correct
22 Correct 68 ms 4808 KB Output is correct
23 Correct 73 ms 4796 KB Output is correct
24 Correct 69 ms 4796 KB Output is correct
25 Correct 69 ms 4796 KB Output is correct
26 Correct 76 ms 5180 KB Output is correct