답안 #715295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715295 2023-03-26T11:47:39 Z ac2hu Let's Win the Election (JOI22_ho_t3) C++14
0 / 100
1 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
using ld = long double;
void pmin(ld &a, ld c){a = min(a, c);}
struct cst{
    int a, b;
} c[N];
int n, k;
ld dp[N][N][N];
signed main() {
    iostream::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 0;i<n;i++)cin >> c[i + 1].a >> c[i + 1].b;
    sort(c + 1, c + n + 1, [&](cst a, cst b){
        return a.b < b.b;
    });
    for(int i= 0;i<=n;i++){
        for(int places = 0;places<=n;places++){
            for(int c = 0;c<=n;c++)dp[i][places][c] = 1e18;
        }
    }
    dp[0][0][0] = 0; 
    for(int i = 1;i<=n;i++){
        for(int places = 0;places<=i;places++){
            for(int collab = 0;collab<=places;collab++){
                dp[i][places][collab] = dp[i - 1][places][collab];
                if(places != 0)
                    pmin(dp[i][places][collab], dp[i - 1][places - 1][collab] + ((ld)c[i].a)/(collab + 1));
                if(collab != 0 && c[i].b != -1)
                    pmin(dp[i][places][collab], dp[i - 1][places - 1][collab - 1] + ((ld)c[i].b)/(collab));
            }
        }
    }
    ld mn = 1e18;
    for(int collab = 0;collab<=k;collab++)pmin(mn, dp[n][k][collab]);
    cout << setprecision(10) << fixed << mn << "\n";
}
# 결과 실행 시간 메모리 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 Runtime error 1 ms 464 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 1 ms 464 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 420 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 420 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 420 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 1 ms 464 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -