Submission #828357

# Submission time Handle Problem Language Result Execution time Memory
828357 2023-08-17T08:51:23 Z RaresFelix Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
2500 ms 984592 KB
#include <bits/stdc++.h>

using namespace std;
const int MN = 501;
const double INF = 1e18;

struct stat {
    double a, b;
    bool operator < (const stat &rhs) const {
        return make_pair((b < 0) ? INF : b, -a) < make_pair((rhs.b < 0) ? INF : rhs.b, -rhs.a);
    }
} A[MN];
int n, k;
double DP[MN][MN][MN];
int main() {
    cin >> n >> k;
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= n + 1; ++j) 
            for(int w = 0; w <= k; ++w)
                DP[i][j][w] = INF;
    for(int i = 1; i <= n; ++i) {
        cin >> A[i].a >> A[i].b;
    }
    sort(A + 1, A + n + 1);
    DP[0][1][0] = 0; 
    for(int i = 0; i < n; ++i) {
        for(int j = 1; j <= n + 1; ++j) {
            for(int w = 0; w <= k; ++w) {
                ///propag (i, j, w) in orasul i + 1
                DP[i + 1][j][w] = min(DP[i + 1][j][w], DP[i][j][w]);
                DP[i + 1][j][w + 1] = min(DP[i + 1][j][w + 1], DP[i][j][w] + (A[i + 1].a / double(j)));
                if(A[i + 1].b >= 0)
                    DP[i + 1][j + 1][w + 1] = min(DP[i + 1][j + 1][w + 1], DP[i][j][w] + (A[i + 1].b / double(j)));
            }
        } 
    }
    double re = INF;
    for(int j = 1; j <= n + 1; ++j)
        re = min(re, DP[n][j][k]);
    cout << fixed << setprecision(10) << re << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 2567 ms 984560 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 2567 ms 984560 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 572 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 544 KB Output is correct
4 Correct 1 ms 568 KB Output is correct
5 Correct 1 ms 544 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Incorrect 1 ms 596 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 572 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 544 KB Output is correct
4 Correct 1 ms 568 KB Output is correct
5 Correct 1 ms 544 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Incorrect 1 ms 596 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 572 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 544 KB Output is correct
4 Correct 1 ms 568 KB Output is correct
5 Correct 1 ms 544 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Incorrect 1 ms 596 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2598 ms 984592 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 2567 ms 984560 KB Time limit exceeded
6 Halted 0 ms 0 KB -