답안 #878700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878700 2023-11-25T05:48:04 Z Faisal_Saqib Sure Bet (CEOI17_sure) C++17
100 / 100
110 ms 4388 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{
    cout<<fixed<<setprecision(4);
	int n;
	cin>>n;
	vector<double> a,b;
	for(int i=0;i<n;i++)
	{
		double x,y;
		cin>>x>>y;
		a.push_back(x);
		b.push_back(y);
	}
	sort(rbegin(a),rend(a));
	sort(rbegin(b),rend(b));
	vector<double> pre0,pre1;
	pre1=pre0={0};
	for(int i=0;i<n;i++)
	{
		pre0.push_back(pre0.back()+a[i]);
		pre1.push_back(pre1.back()+b[i]);
	}
	pre1.push_back(pre1.back());
	pre0.push_back(pre0.back());
	int j=0;
	double ans=0;
	n++;
	for(int i=0;i<n;i++)
	{
		while(j<n and pre1[j]<pre0[i])
		{
			j++;
		}
		if(pre0[i]<=pre1[j])
			ans=max(ans,pre0[i]-i-j);
	}
	j=0;
	for(int i=0;i<n;i++)
	{
		while(j<=n and pre0[j]<pre1[i])
		{
			j++;
		}
		if(pre0[j]>=pre1[i])
			ans=max(ans,pre1[i]-i-j);
	}
	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 98 ms 4256 KB Output is correct
18 Correct 98 ms 4212 KB Output is correct
19 Correct 98 ms 4284 KB Output is correct
20 Correct 99 ms 4200 KB Output is correct
21 Correct 110 ms 4284 KB Output is correct
22 Correct 98 ms 4336 KB Output is correct
23 Correct 100 ms 4388 KB Output is correct
24 Correct 98 ms 4284 KB Output is correct
25 Correct 98 ms 4172 KB Output is correct
26 Correct 108 ms 4292 KB Output is correct