Submission #973727

# Submission time Handle Problem Language Result Execution time Memory
973727 2024-05-02T10:12:23 Z berr Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
2500 ms 272712 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
 
double dp[N][N];
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k; cin >> n >> k;

    vector<array<int, 2>> a(n);
    int c=0;
    for(auto &[i, l]: a) cin >> i >> l, c+=(l!=-1);
    
    sort(a.begin(), a.end(), [&](auto x, auto y){
        if(x[1]==y[1]) return x[0] < y[0];
        else if(y[1]==-1) return true;
        else if(x[1]==-1) return false;
         return x[1]<y[1]; 
    }); 

    map<array<double, 3>, double> mp;
    
    mp[{0, 0, 0}]=0;
   

        for(int i=0; i<n; i++){
            vector<array<double, 4>> be;
            for(auto [b, j]: mp){
             //   cout<<j<<"\n";
                if(a[i][1]!=-1){
                    be.push_back({b[0]+((double)a[i][1]/(double)(b[1]+1)), b[1]+1, b[2], j});
                }
                be.push_back({b[0], b[1], b[2]+1.0, j+(double)a[i][0]});
            }

            for(auto i: be){
           //     cout<<i[0]<<" "<<i[1]<<" "<<i[2]<<" "<<i[3]<<"\n";
                if(mp.count({i[0], i[1], i[2]})){
                    mp[{i[0], i[1], i[2]}]=min( mp[{i[0], i[1], i[2]}], i[3]);
                }

                 mp[{i[0], i[1], i[2]}]=i[3];
            }
        }

        double ans=1e9;
     
        for(auto [b, j]: mp){
         ///   cout<<j<<"\n";
            if(b[1]+b[2]==k){
                ans=min(ans, b[0]+j/(b[1]+1));
            }
        }
      
        cout<<setprecision(9)<<ans<<"\n";
    

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2559 ms 272712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -