답안 #891159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891159 2023-12-22T09:10:52 Z vjudge1 Sure Bet (CEOI17_sure) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pf push_front
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()

void boost(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	return;
}

void solve(){
	int n;
	cin>>n;
	ld a[n],b[n];
	for(int i=0; i<n; i++) cin>>a[i]>>b[i];
	sort(a,a+n,greater<double>());
	sort(b,b+n,greater<double>());
	ld ans=0;
	ld p1=1,p2=1;
	ld suma=a[0],sumb=b[0];
	while(p1<n||p2<n){
		if(p1==n||p2==n){
			if(p1==n){
				sumb+=b[p2];
				p2++;
			}
			else{
				suma+=a[p1];
				p1++;
			}
		}
		else{
			if(suma>sumb){
				sumb+=b[p2];
				p2++;
			}
			else{
				suma+=a[p1];
				p1++;
			}
		}
		ans=max(ans,min(suma,sumb)-p1-p2);
	}
	cout<<setprecision(15)<<ans;
	return;
}

int main(){
	boost();
	solve();
	return 0;
}

Compilation message

sure.cpp: In function 'void solve()':
sure.cpp:33:12: error: invalid types 'long double [n][long double]' for array subscript
   33 |     sumb+=b[p2];
      |            ^
sure.cpp:37:12: error: invalid types 'long double [n][long double]' for array subscript
   37 |     suma+=a[p1];
      |            ^
sure.cpp:43:12: error: invalid types 'long double [n][long double]' for array subscript
   43 |     sumb+=b[p2];
      |            ^
sure.cpp:47:12: error: invalid types 'long double [n][long double]' for array subscript
   47 |     suma+=a[p1];
      |            ^