답안 #534167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534167 2022-03-08T01:48:11 Z PikaQ Let's Win the Election (JOI22_ho_t3) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define forn(i,n) for(int i = 0;i < (n);i++)
#define Forn(i,n) for(int i = 1;i <= (n);i++)
#define all(p) p.begin(),p.end()
#define pb push_back
#define F first
#define S second
#define rz resize
#define sz(x) x.size()
#define int long long
#define vi vector<int>
#define pii pair<int,int>
using namespace std;
const int N = 2e5+9;
const int INF = 1e18+9;

int n,k;
vector<pii> a;
#define double long double

pii operator<(const pii &a,const pii &b){return (x.F < y.F || (x.F == y.F && x.S > y.S));}

void solve(){
	cin >> n >> k;
	a.rz(n);
	forn(i,n){ 
		cin >> a[i].S >> a[i].F;
		if(a[i].F == -1) a[i].F = 1e18+9;
	}
	sort(all(a),cmp);
	double ans = INF;
	double res = 0;
	for(int i = 0;i <= k;i++){
		if(i) {
			res += (double)a[i-1].F/(i);
		}
		vi b;
		for(int j = i;j < n;j++){
			b.pb(a[j].S);
		}
		sort(all(b));
		int tr = 0;
		for(int r = 0;r < k-i;r++){
			tr += b[r];
		}
		cout << res << ' ' << tr << '\n';
		ans = min(ans,(double) res + (double)tr / (i+1));
	}
	cout << ans << '\n';
}
 
signed main(){
	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Compilation message

Main.cpp: In function 'std::pair<long long int, long long int> operator<(const std::pair<long long int, long long int>&, const std::pair<long long int, long long int>&)':
Main.cpp:21:50: error: 'x' was not declared in this scope
   21 | pii operator<(const pii &a,const pii &b){return (x.F < y.F || (x.F == y.F && x.S > y.S));}
      |                                                  ^
Main.cpp:21:56: error: 'y' was not declared in this scope
   21 | pii operator<(const pii &a,const pii &b){return (x.F < y.F || (x.F == y.F && x.S > y.S));}
      |                                                        ^
Main.cpp: In function 'void solve()':
Main.cpp:30:14: error: 'cmp' was not declared in this scope; did you mean 'bcmp'?
   30 |  sort(all(a),cmp);
      |              ^~~
      |              bcmp