답안 #770382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
770382 2023-07-01T06:31:37 Z Trisanu_Das Let's Win the Election (JOI22_ho_t3) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k; cin >> n >> k;
	vector<pair<int, int> > st(n);
	for (int i = 0; i < n; ++i) {
		cin >> st[i].a >> st[i].b;
		if (st[i].b == -1) st[i].b = 1'000'000'000;
	}
	sort(begin(st), end(st));
 
	double ans = 1e18;
	for (int x = 0; x < k + 1; x++) {
		vector< vector<double> > dp(n + 1, vector<double>(k - x + 1, 1e18));
		dp[0][0] = 0;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < k - x + 1; ++j) {
				if (j < k - x) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + (double) st[i].a / (x + 1));
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (i - j < x ? (double) st[i].b / (i - j + 1) : .0));
			}
		ans = min(ans, dp[n][k - x]);
	}
 
	cout << setprecision(9) << fixed << ans << '\n';
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:9:16: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'a'
    9 |   cin >> st[i].a >> st[i].b;
      |                ^
Main.cpp:9:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'b'
    9 |   cin >> st[i].a >> st[i].b;
      |                           ^
Main.cpp:10:13: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'b'
   10 |   if (st[i].b == -1) st[i].b = 1'000'000'000;
      |             ^
Main.cpp:10:28: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'b'
   10 |   if (st[i].b == -1) st[i].b = 1'000'000'000;
      |                            ^
Main.cpp:20:87: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'a'
   20 |     if (j < k - x) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + (double) st[i].a / (x + 1));
      |                                                                                       ^
Main.cpp:21:77: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'b'
   21 |     dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (i - j < x ? (double) st[i].b / (i - j + 1) : .0));
      |                                                                             ^