제출 #1278007

#제출 시각아이디문제언어결과실행 시간메모리
1278007minggaLet's Win the Election (JOI22_ho_t3)C++20
100 / 100
162 ms2424 KiB
// Author: caption_mingle #include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ll long long const int mod = 1e9 + 7; const int inf = 2e9; const int N = 505; int n, k; double dp[N][N]; pair<int, int> d[N]; signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n >> k; for(int i = 1; i <= n; i++) { int a, b; cin >> a >> b; if(b == -1) b = inf; d[i] = {b, a}; } sort(d + 1, d + n + 1); double ans = inf; for(int i = 0; i <= k; i++) { for(int j = 0; j <= n; j++) { for(int t = 0; t <= k; t++) { dp[j][t] = 2e9; } } dp[0][0] = 0; // cerr << "TURN " << i << ln; for(int j = 1; j <= n; j++) { for(int t = 0; t <= j; t++) { if(t > 0) dp[j][t] = min(dp[j][t], dp[j - 1][t - 1] + d[j].se / (double)(i + 1)); if(j - t <= i) { dp[j][t] = min(dp[j][t], dp[j - 1][t] + d[j].fi / (double)(j - t)); } else { dp[j][t] = min(dp[j][t], dp[j - 1][t]); } // cerr << j << ' ' << t << ' ' << dp[j][t] << ln; } } ans = min(ans, dp[n][k - i]); } cout << setprecision(6) << fixed << ans << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:24:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |                 freopen(task ".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:25:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |                 freopen(task ".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...