Submission #685003

# Submission time Handle Problem Language Result Execution time Memory
685003 2023-01-23T04:51:19 Z Nuraly_Serikbay Sure Bet (CEOI17_sure) C++14
60 / 100
2000 ms 3176 KB
/* Speech to the young */

//#include <bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

/*
#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")
*/
 

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define YOSIK() ios_base::sync_with_stdio(0),cin.tie(0)
#define int long long
#define cube (x) ((x) * (x) * (x))

int gcd (int a, int b) {if (b == 0){return a;}else {return gcd (b, a % b);}}
void pre(int a) { cout<<fixed<<setprecision(a); }
int bitcount (int x) {return __builtin_popcount	(x);}

const int N = 2e6 + 10;
const int INF = 1e18 + 1;
const int MOD = 1e9 + 7;
const int P = 31;
const double eps = 1e-19;
long double pi = 3.1415926535897323;

double a[N], b[N], res;
int n;

void Solution () {
	cin >> n;
	for (int i = 1; i <= n; ++ i) cin >> a[i] >> b[i];
	sort (a + 1, a + n + 1), reverse (a + 1, a + n + 1);
	sort (b + 1, b + n + 1), reverse (b + 1, b + n + 1);
	double suma = 0;
	for (int i = 1; i <= n; ++ i) {
		suma += a[i];
		double sumb = 0;
		for (int j = 1; j <= n; ++ j) {
			sumb += b[j];
		//	cout << suma << ' ' << sumb << ' ' << i << ' ' << j << '\n';
			res = max (res, min (suma, sumb) - (double)(i + j));
		}
	}
	cout << fixed << setprecision(4) << res;
	return; 
}

signed main () {
	YOSIK();
//	precalc();
	int T = 1;
//	cin >> T;
	while (T --) Solution ();
	exit (0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 3 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 3 ms 352 KB Output is correct
17 Execution timed out 2085 ms 3176 KB Time limit exceeded
18 Halted 0 ms 0 KB -