답안 #834575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
834575 2023-08-22T15:29:26 Z LeVanThuc Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
5 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
    if(x<y)
    {
        x=y;
        return 1;
    }
    return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
    if(x>y)
    {
        x=y;
        return 1;
    }
    return 0;
}
void online()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef thuc
    freopen("input.inp", "r", stdin);
    freopen("output.out","w", stdout);
#else
#endif
}
const ll N=1e6+10;
pll a[N];
ll n,k;
bool cmp2(pll a,pll b)
{
    return a.se==b.se?a.fi>b.fi:a.se<b.se;
}
int main()
{
    online();
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].fi>>a[i].se;
        if(a[i].se==-1) a[i].se=1e12;
    }
    sort(a+1,a+n+1,cmp2);
    ld ans=1e18;
    ld base=0;
    for(ll i=0;i<=k;i++)
    {
        vector<ll> vt;
        if(i>0)
        base+=(ld)a[i].se/(ld)i;
        ld cr=base;
        for(int j=i+1;j<=n;j++)
        {
            vt.push_back(a[j].fi);
        }
        sort(vt.begin(),vt.end());
        for(int j=0;j<k-i;j++)
        {
            ll z=vt[j];
            cr+=(ld)vt[j]/(ld)(i+1);
        }
        minimize(ans,cr);
    }
    cout<<fixed<<setprecision(10)<<ans;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:74:16: warning: unused variable 'z' [-Wunused-variable]
   74 |             ll z=vt[j];
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 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 384 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 360 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 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 384 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 360 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 3 ms 320 KB Output is correct
14 Correct 2 ms 308 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 3 ms 328 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 3 ms 328 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 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 384 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 360 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 3 ms 320 KB Output is correct
14 Correct 2 ms 308 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 3 ms 328 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 3 ms 328 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Incorrect 1 ms 212 KB Output isn't correct
30 Halted 0 ms 0 KB -