답안 #1087534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087534 2024-09-12T21:25:34 Z I_am_Polish_Girl Let's Win the Election (JOI22_ho_t3) C++14
0 / 100
447 ms 1048576 KB
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <cmath>
#include <random>
#include <chrono>
#include <iomanip>
#include <iostream>

using namespace std;

#define double long double

int log_ = 3;
int inf = 2000000000000000000;
int mod = 1102024631;

int p = 505;


bool cmp(pair <int, int> a, pair <int, int> b)
{
    if (a.second < b.second)
    {
        return true;
    }

    return false;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n , k;
    cin >> n >> k;

    vector <pair <int, int>> vp(n);

    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;

        vp[i] = { a,  b };
    }

    sort(vp.begin(), vp.end(), cmp);

    vector <vector <vector <double>>> dp0(n+1);
    vector <vector <vector <double>>> dp1;

    for (int i = 0; i <= n; i++)
    {
        dp0[i].resize(n + 1);

        for (int j = 0; j <= n; j++)
        {
            dp0[i][j].resize(n + 1 , inf);
        }
    }

    for (int i = 0; i <= n; i++)
    {
        dp0[0][0][i] = 0;
    }

    dp1 = dp0;

    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i <= n; i++)
        {
            for (int j = 0; j <= n; j++)
            {
                for (int col = 0; col <= n; col++)
                {
                    if (i > 0)
                    {
                        if (vp[k].second != -1)
                        {
                            dp1[i][j][col] = min(dp1[i][j][col], dp0[i - 1][j][col] + ((0. + vp[k].second) / i));
                        }
                    }

                    if (j > 0)
                    {
                        dp1[i][j][col] = min(dp1[i][j][col], dp0[i][j - 1][col] + ((0. + vp[k].first) / (col+1)));
                    }
                }
            }
        }

        dp0 = dp1;
    }

    
    double ans = inf;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            for (int col = 0; col <= n; col++)
            {
                if (col <= k)
                {
                    if (i + j == k)
                    {
                        if (i == col)
                        {
                            ans = dp0[i][j][col];
                        }
                    }
                }
            }
        }
    }

    cout << ans;
}

Compilation message

Main.cpp:21:11: warning: overflow in conversion from 'long int' to 'int' changes value from '2000000000000000000' to '1321730048' [-Woverflow]
   21 | int inf = 2000000000000000000;
      |           ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 447 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -