Submission #3783586


Source Code Expand

// Last Change:                   12/13/2018 20:11:37.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <list>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

struct Mixture {
  int w;
  int p;
};
struct Cal {
  ll ans;
  int index;
  bool operator<(const Cal &another) const {
    return ans < another.ans;
  }
};

int main() {
  int N, K;
  cin >> N >> K;
  vector<Mixture> a(N + 1);
  vector<Cal> b(N);
  a[N].w = 2000000000;
  a[N].p = 200;
  for (int i = 0; i < N; i++) {
    cin >> a[i].w >> a[i].p;
  }

  for (int i = 0; i < N; i++) {
    b[i].index = i;
    b[i].ans = (a[i].w * a[i].p + a[N].w * a[N].p) / (a[i].w + a[N].w);
  }
  sort(b.begin(), b.end());
  ll sumSolt = 0;
  ll sumW = 0;
  for (int i = 0; i < K; i++) {
    sumW += a[b[N - 1 - i].index].w;
    sumSolt += a[b[N - 1 - i].index].w * a[b[N - i - 1].index].p;
  }
  double ans = sumSolt / sumW;
  printf("%.9f", ans);
}

Submission Info

Submission Time
Task D - 食塩水
User Nagatuki
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1141 Byte
Status WA
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
WA × 2
WA × 22
Set Name Test Cases
Sample s0.txt, s1.txt
All 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 WA 3 ms 256 KB
001.txt WA 1 ms 256 KB
002.txt WA 3 ms 256 KB
003.txt WA 2 ms 256 KB
004.txt WA 3 ms 256 KB
005.txt WA 3 ms 256 KB
006.txt WA 3 ms 256 KB
007.txt WA 3 ms 256 KB
008.txt WA 3 ms 256 KB
009.txt WA 1 ms 256 KB
010.txt WA 3 ms 256 KB
011.txt WA 2 ms 256 KB
012.txt WA 3 ms 256 KB
013.txt WA 2 ms 256 KB
014.txt WA 3 ms 256 KB
015.txt WA 3 ms 256 KB
016.txt WA 3 ms 256 KB
017.txt WA 2 ms 256 KB
018.txt WA 3 ms 256 KB
019.txt WA 2 ms 256 KB
s0.txt WA 1 ms 256 KB
s1.txt WA 1 ms 256 KB