Submission #937408

# Submission time Handle Problem Language Result Execution time Memory
937408 2024-03-04T02:47:33 Z Marco_Escandon Let's Win the Election (JOI22_ho_t3) C++11
21 / 100
324 ms 2904 KB
#include<bits/stdc++.h>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(15);
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
#define x first
#define y second
pair<double,double> cad[501];
double P[501];
void PSN(ll n,ll m)
{
    for(int i=0; i<n; i++)
    {
        priority_queue<double> q;
        for(int j = i+1; j <=n; j++) q.push(cad[j].second);
        while(q.size()>m-i) q.pop();
        while(!q.empty()) {P[i]+=q.top();q.pop();}
        //cout<<P[i]<<" ";
    }
}
double sol(ll l,ll n,ll m)
{
    vector<vector<double>> dp(n+1,vector<double>(l+2,1e9));
    double bs=1e9;
    dp[0][1]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=l; j++)
        {
            if(j!=1)
                dp[i][j]=dp[i-1][j-1]+cad[i].first/(j-1);
            dp[i][j]=min(dp[i][j],dp[i-1][j]+cad[i].second/(double)l);
            if(j==l)
            {
                bs=min(bs,P[i]/l+dp[i][j]);
            }
                
        }
    }
    return bs;
}
int main()
{
    optimizar_io
    ll n,m;
    cin>>n>>m;
    cad[0]={-1,-1};
    for(int i=1; i<=n; i++)
    {
        cin>>cad[i].second>>cad[i].first;
        if(cad[i].x==-1)
            cad[i].x=1e16;
    }
    sort(cad,cad+n+1);
    PSN(n,m);
    double bs=1e9;
    for (int i = 1; i <= m+1; i++) {
        double f1=sol(i,n,m);
        //cout<<f1<<"\n";
        bs=min(bs,f1);
    }
    cout<<bs;
}

Compilation message

Main.cpp: In function 'void PSN(ll, ll)':
Main.cpp:16:23: warning: comparison of integer expressions of different signedness: 'std::priority_queue<double>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   16 |         while(q.size()>m-i) q.pop();
      |               ~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 956 KB Output is correct
6 Correct 25 ms 1136 KB Output is correct
7 Correct 77 ms 1712 KB Output is correct
8 Correct 176 ms 2288 KB Output is correct
9 Correct 289 ms 2692 KB Output is correct
10 Correct 154 ms 2152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 956 KB Output is correct
6 Correct 25 ms 1136 KB Output is correct
7 Correct 77 ms 1712 KB Output is correct
8 Correct 176 ms 2288 KB Output is correct
9 Correct 289 ms 2692 KB Output is correct
10 Correct 154 ms 2152 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 32 ms 1292 KB Output is correct
13 Correct 34 ms 1256 KB Output is correct
14 Correct 33 ms 1352 KB Output is correct
15 Correct 148 ms 2184 KB Output is correct
16 Correct 147 ms 2060 KB Output is correct
17 Correct 145 ms 2160 KB Output is correct
18 Correct 301 ms 2720 KB Output is correct
19 Correct 297 ms 2860 KB Output is correct
20 Correct 292 ms 2728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 300 ms 2904 KB Output is correct
2 Correct 298 ms 2704 KB Output is correct
3 Correct 324 ms 2752 KB Output is correct
4 Correct 293 ms 2772 KB Output is correct
5 Correct 291 ms 2740 KB Output is correct
6 Correct 291 ms 2672 KB Output is correct
7 Correct 293 ms 2736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 956 KB Output is correct
6 Correct 25 ms 1136 KB Output is correct
7 Correct 77 ms 1712 KB Output is correct
8 Correct 176 ms 2288 KB Output is correct
9 Correct 289 ms 2692 KB Output is correct
10 Correct 154 ms 2152 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 32 ms 1292 KB Output is correct
13 Correct 34 ms 1256 KB Output is correct
14 Correct 33 ms 1352 KB Output is correct
15 Correct 148 ms 2184 KB Output is correct
16 Correct 147 ms 2060 KB Output is correct
17 Correct 145 ms 2160 KB Output is correct
18 Correct 301 ms 2720 KB Output is correct
19 Correct 297 ms 2860 KB Output is correct
20 Correct 292 ms 2728 KB Output is correct
21 Incorrect 0 ms 600 KB Output isn't correct
22 Halted 0 ms 0 KB -