답안 #638714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638714 2022-09-07T05:24:18 Z jamezzz Let's Win the Election (JOI22_ho_t3) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define pf printf
#define sf scanf
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

#define maxn 505
#define INF 1023456789

int n,k,a[maxn],b[maxn];
bool have[maxn];
vector<ii> v;
ld memo[maxn][maxn];

int main(){
	sf("%d%d",&n,&k);
	for(int i=0;i<n;++i){
		int x,y;
		sf("%d%d",&x,&y);
		if(y==-1)y=INF;
		v.push_back({x,y});
	}
	sort(v.begin(),v.end(),[](ii &a,ii &b){
		if(a.se==b.se)return a.fi>b.fi;
		else return a.se<b.se;
	});
	for(int i=0;i<n;++i){
		tie(a[i],b[i])=v[i];
		if(b[i]!=INF)have[i]=true;
	}
	for(int i=0;i<=n+1;++i){
		for(int j=0;j<=n+1;++j){
			memo[i][j]=INF;
		}
	}
	memo[0][0]=0;
	for(int pos=0;pos<n;++pos){
		for(int ppl=n;ppl>=0;--ppl){
			for(int vote=n;vote>=0;--vote){
				ld ans=memo[ppl][vote];
				if(vote!=0)ans=min(ans,memo[ppl][vote-1]+(ld)a[pos]/(ppl+1));
				if(vote!=0&&ppl!=0&&have[pos]){
					ans=min(ans,memo[ppl-1][vote-1]+(ld)b[pos]/ppl);
				}
				memo[ppl][vote]=ans;
			}
		}
	}
	ld ans=INF;
	for(int i=0;i<=n;++i)ans=min(ans,memo[i][k]);
	pf("%Lf\n",ans);
}

Compilation message

Main.cpp: In lambda function:
Main.cpp:27:8: error: 'ii' {aka 'struct std::pair<int, int>'} has no member named 'se'
   27 |   if(a.se==b.se)return a.fi>b.fi;
      |        ^~
Main.cpp:27:14: error: 'ii' {aka 'struct std::pair<int, int>'} has no member named 'se'
   27 |   if(a.se==b.se)return a.fi>b.fi;
      |              ^~
Main.cpp:27:26: error: 'ii' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   27 |   if(a.se==b.se)return a.fi>b.fi;
      |                          ^~
Main.cpp:27:31: error: 'ii' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   27 |   if(a.se==b.se)return a.fi>b.fi;
      |                               ^~
Main.cpp:28:17: error: 'ii' {aka 'struct std::pair<int, int>'} has no member named 'se'
   28 |   else return a.se<b.se;
      |                 ^~
Main.cpp:28:22: error: 'ii' {aka 'struct std::pair<int, int>'} has no member named 'se'
   28 |   else return a.se<b.se;
      |                      ^~
Main.cpp: In function 'int main()':
Main.cpp:19:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  sf("%d%d",&n,&k);
      |    ^
Main.cpp:22:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   sf("%d%d",&x,&y);
      |     ^