Submission #891766

# Submission time Handle Problem Language Result Execution time Memory
891766 2023-12-24T03:17:23 Z 12345678 Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
5 ms 604 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=505;
int n, k, a[nx], b[nx], cnt, c[nx];
double tmp, ans=DBL_MAX;
vector<pair<int, int>> v;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>k;
    for (int i=1; i<=n; i++) cin>>a[i]>>b[i], cnt+=(b[i]!=-1), v.push_back({(b[i]==-1)?1e9:b[i], i});
    sort(v.begin(), v.end());
    for (int i=0; i<=min(cnt, k); i++)
    {
        double res=0;
        vector<int> t;
        for (int j=1; j<=n; j++) if (!c[j]) t.push_back(a[j]);
        sort(t.begin(), t.end());
        for (int j=0; j+1+i<=k; j++) res+=(((double)t[j])/(i+1));
        ans=min(ans, tmp+res);
        //cout<<i<<' '<<tmp<<' '<<res<<' '<<ans<<'\n';
        if (i!=k) tmp+=((double)v[i].first)/(i+1), c[v[i].second]=1;
    }
    printf("%.5llf", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:27:18: warning: use of 'll' length modifier with 'f' type character has either no effect or undefined behavior [-Wformat=]
   27 |     printf("%.5llf", ans);
      |                  ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -