제출 #1337009

#제출 시각아이디문제언어결과실행 시간메모리
1337009wedonttalkanymoreLet's Win the Election (JOI22_ho_t3)C++20
0 / 100
65 ms456 KiB
#include <bits/stdc++.h>
// #include <coin.h>
/*
    Chang ki si xuyen man dem
    Di lac vao trong giac mong
*/
using namespace std;
using ll = long long;

#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second

const ll N = 5e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 19;

int n, k;
struct item {
    int x, y;
};
item a[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen(".inp", "r")) {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].x >> a[i].y;
        if (a[i].y == -1) a[i].y = inf;
    }
    sort(a + 1, a + n + 1, [](item x, item y) {
        if (x.y == y.y) return x.x > y.x;
        return x.y < y.y;
    });
    for (int i = 1; i <= n; i++) cout << a[i].x << ' ' << a[i].y << '\n';
    double ans = 1e18;
    for (int i = 1; i <= k; i++) {
        vector <double> dp(n + 1, inf);
        dp[0] = 0.0;
        for (int j = 1; j <= n; j++) {
            for (int x = j - 1; x >= 0; x--) {
                int t = j - x;
                dp[x + 1] = min(dp[x + 1], dp[x] + a[j].x * 1.0 / i);
                if (t < i) {
                    if (a[j].y != -1) dp[x] += a[j].y * 1.0 / t;
                    else dp[x] = inf;
                }
            }
        }
        ans = min(ans, dp[k - i + 1]);
    }
    cout << ans << '\n';
    return 0;
}

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

Main.cpp: In function 'int main()':
Main.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(".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...