답안 #753815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753815 2023-06-06T06:14:01 Z bgnbvnbv Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
1609 ms 8356 KB
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e8;
const ll mod=1e9+7;

ll n,k;
struct qq
{
    ll a,b;
    bool operator<(const qq&o)
    {
        if(b==o.b) return a<o.a;
        return b<o.b;
    }
}a[maxN];
using ld=long double;
ld dp[2][505][505];
void solve()
{
    cin >> n >> k;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i].a >> a[i].b;
        if(a[i].b==-1) a[i].b=1e14;
    }
    sort(a+1,a+n+1);
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++) dp[0][i][j]=inf;
    }
    dp[0][0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            for(int q=0;q<=k;q++)
            {
                dp[i&1][j][q]=dp[(i-1)&1][j][q];
                //lay vote
                if(q>=1) dp[i&1][j][q]=min(dp[i&1][j][q],dp[(i-1)&1][j][q-1]+(ld)a[i].a/(j+1));
                //lay nguoi
                if(j>=1&&q>=1) dp[i&1][j][q]=min(dp[i&1][j][q],dp[(i-1)&1][j-1][q-1]+(ld)a[i].b/(j));
            }
        }
    }
    ld ans=inf;
    //cout << dp[1][1][1]<<'\n';
    for(int j=0;j<=n;j++)
    {
        ans=min(ans,dp[n&1][j][k]);
    }
    cout << fixed<< setprecision(5)<<ans;
}
int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 152 ms 5132 KB Output is correct
6 Correct 403 ms 6280 KB Output is correct
7 Correct 780 ms 8236 KB Output is correct
8 Correct 1121 ms 8248 KB Output is correct
9 Correct 1554 ms 8256 KB Output is correct
10 Correct 1061 ms 8356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 152 ms 5132 KB Output is correct
6 Correct 403 ms 6280 KB Output is correct
7 Correct 780 ms 8236 KB Output is correct
8 Correct 1121 ms 8248 KB Output is correct
9 Correct 1554 ms 8256 KB Output is correct
10 Correct 1061 ms 8356 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 482 ms 6664 KB Output is correct
13 Correct 464 ms 6612 KB Output is correct
14 Correct 515 ms 6612 KB Output is correct
15 Correct 1042 ms 8248 KB Output is correct
16 Correct 1117 ms 8248 KB Output is correct
17 Correct 1061 ms 8248 KB Output is correct
18 Correct 1500 ms 8248 KB Output is correct
19 Correct 1484 ms 8244 KB Output is correct
20 Correct 1472 ms 8248 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 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 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 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 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1609 ms 8244 KB Output isn't correct
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 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 152 ms 5132 KB Output is correct
6 Correct 403 ms 6280 KB Output is correct
7 Correct 780 ms 8236 KB Output is correct
8 Correct 1121 ms 8248 KB Output is correct
9 Correct 1554 ms 8256 KB Output is correct
10 Correct 1061 ms 8356 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 482 ms 6664 KB Output is correct
13 Correct 464 ms 6612 KB Output is correct
14 Correct 515 ms 6612 KB Output is correct
15 Correct 1042 ms 8248 KB Output is correct
16 Correct 1117 ms 8248 KB Output is correct
17 Correct 1061 ms 8248 KB Output is correct
18 Correct 1500 ms 8248 KB Output is correct
19 Correct 1484 ms 8244 KB Output is correct
20 Correct 1472 ms 8248 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Incorrect 1 ms 340 KB Output isn't correct
30 Halted 0 ms 0 KB -