Submission #703353

# Submission time Handle Problem Language Result Execution time Memory
703353 2023-02-27T06:40:23 Z Aestivate Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
2 ms 340 KB
#include<bits/stdc++.h>
#include<random>
using namespace std;

template<typename T> void _do(T x){cerr<<x<<"\n";}
template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);}
#define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__);

#define float double
#define ss(n) fixed<<setprecision(n) 
#define ll long long
#define int ll
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define rep(i,a) for(int i=1;i<=a;i++)
#define rep0(i,a) for(int i=0;i<a;i++)
#define F first
#define S second
#define uni(a) a.resize(distance(a.begin(),unique(a.begin(),a.end())));
#define unisort(a) sort(a.begin(),a.end()); uni(a);

ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);}

const ld pi=3.14159265358979323846264338327950288419716939931;
const int lar=3e18;
const int mol1=1e9+7;
const int mol2=998244353;
const int MX=2e5+5;

vector<pair<int,int>>no;
vector<pair<pair<int,int>,int>>can;

void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n+1],b[n+1];
    rep(i,n){
        cin>>a[i]>>b[i];
        if(b[i]!=-1) can.pb({{b[i],a[i]},i});
        no.pb({a[i],i});
    }
    sort(can.begin(),can.end());
    sort(no.begin(),no.end());
    double ans=lar;
    for(int i=0;i<=can.size();i++){
        double now=0;double hh=1;
        int vis[n+1]={0};int st=0;
        rep0(j,i){
            now+=(double)can[j].F.F/hh;
            hh++;
            st++;vis[can[j].S]=1;
            if(st==k) break;
            
        }
        if(st==k){
            ans=min(ans,now);
            break;
        }
        rep0(j,no.size()){
            if(vis[no[j].S]) continue;
            vis[no[j].S]=1;
            now+=(double)no[j].F/hh;
            st++;if(st==k) break;
        }
        ans=min(ans,now);
    }
    cout<<ss(3)<<ans<<"\n";
}   

signed main()
{
    IO
    solve();
    return 0;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:48:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int i=0;i<=can.size();i++){
      |                 ~^~~~~~~~~~~~
Main.cpp:18:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | #define rep0(i,a) for(int i=0;i<a;i++)
......
   62 |         rep0(j,no.size()){
      |              ~~~~~~~~~~~        
Main.cpp:62:9: note: in expansion of macro 'rep0'
   62 |         rep0(j,no.size()){
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Incorrect 0 ms 212 KB Output isn't correct
30 Halted 0 ms 0 KB -