Submission #2083176


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k;
  cin>>n>>k;
  vi w(n),p(n);
  rep(i,n)cin>>w[i]>>p[i];
  double ok=0;
  double ng=100;
  rep(i,100){
    double mid=(ok+ng)/2;
    vector<double> v(n);
    rep(j,n)
      v[j]=w[j]/mid*p[j]-w[j];
    sort(all(v));
    double sum=0;
    rep(j,k)sum+=v[n-1-j];
    if(sum>0)ok=mid;
    else ng=mid;
  }
  cout<<shosu(10)<<ok<<endl;
}

Submission Info

Submission Time
Task D - 食塩水
User rika0384
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1016 Byte
Status
Exec Time 6 ms
Memory 384 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s0.txt, s1.txt
All 100 / 100 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, s0.txt, s1.txt
Case Name Status Exec Time Memory
000.txt 6 ms 256 KB
001.txt 1 ms 256 KB
002.txt 5 ms 384 KB
003.txt 1 ms 256 KB
004.txt 6 ms 256 KB
005.txt 5 ms 256 KB
006.txt 6 ms 256 KB
007.txt 5 ms 256 KB
008.txt 6 ms 256 KB
009.txt 1 ms 256 KB
010.txt 6 ms 256 KB
011.txt 3 ms 256 KB
012.txt 6 ms 256 KB
013.txt 3 ms 256 KB
014.txt 6 ms 256 KB
015.txt 4 ms 256 KB
016.txt 6 ms 256 KB
017.txt 4 ms 256 KB
018.txt 6 ms 256 KB
019.txt 4 ms 256 KB
s0.txt 1 ms 256 KB
s1.txt 1 ms 256 KB