提出 #41159152


ソースコード 拡げる

#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b){ if (a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if (a < b){a = b; return true;} return false;}

//using mint = modint998244353;
//using mint = modint1000000007;
//using mint = modint;  // mint::set_mod(p); later
//using mint = static_modint<1000000009>;

int main()
{
  cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

  // Input
  int N, M, K;
  cin >> N >> M >> K;
  vector<tuple<double, int, int>> ab, cd;

  for (int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    double c = double(a) * 100 / double(a+b);
    ab.emplace_back(c, a, b);
  }

  for (int i = 0; i < M; i++){
    int c, d;
    cin >> c >> d;
    double e = double(c) * 100 / double(c+d);
    cd.emplace_back(e, c, d);
  }

  // Solve: ニブタン
  sort(ab.rbegin(), ab.rend());
  sort(cd.rbegin(), cd.rend());

  double ng = 100;
  double ok = 0;
  for (int i = 0; i < 100; i++){
    double mid = (ok + ng) / 2;
    ll m = 0;
    for (auto p : ab){
      auto [d1, a, b] = p;
      for (auto q : cd){
	auto [d2, c, d] = q;
	double dens = double(a + c) * 100 / double (a + b + c + d);
	if (dens >= mid) m++;
	if (m > K) break;
      }
      if (m > K) break;
    }

    if (m >= K) ok = mid;
    else ng = mid;
  }
  
  cout << fixed << setprecision(12) << ok << endl;
  return 0;
}

提出情報

提出日時
問題 F - Sugar Water 2
ユーザ unnohideyuki
言語 C++ (GCC 9.2.1)
得点 0
コード長 1624 Byte
結果 TLE
実行時間 4410 ms
メモリ 5600 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 500
結果
AC × 3
AC × 11
TLE × 22
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_biased_00.txt, 02_biased_01.txt, 02_biased_02.txt, 02_biased_03.txt, 02_biased_04.txt, 02_biased_05.txt, 02_biased_06.txt, 02_biased_07.txt, 02_biased_08.txt, 02_biased_09.txt, 03_border_00.txt, 03_border_01.txt, 03_border_02.txt, 03_border_03.txt, 03_border_04.txt, 03_border_05.txt, 03_border_06.txt, 03_border_07.txt, 03_border_08.txt, 03_border_09.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 8 ms 3716 KiB
00_sample_01.txt AC 2 ms 3688 KiB
00_sample_02.txt AC 2 ms 3664 KiB
01_random_00.txt TLE 4410 ms 5500 KiB
01_random_01.txt TLE 4410 ms 5496 KiB
01_random_02.txt TLE 4410 ms 5532 KiB
01_random_03.txt TLE 4410 ms 5448 KiB
01_random_04.txt TLE 4410 ms 5424 KiB
01_random_05.txt TLE 4410 ms 5432 KiB
01_random_06.txt TLE 4410 ms 4236 KiB
01_random_07.txt TLE 4410 ms 4004 KiB
01_random_08.txt TLE 4163 ms 3796 KiB
01_random_09.txt TLE 4410 ms 4132 KiB
02_biased_00.txt TLE 4410 ms 5560 KiB
02_biased_01.txt TLE 4410 ms 5492 KiB
02_biased_02.txt TLE 4410 ms 5572 KiB
02_biased_03.txt TLE 4410 ms 5448 KiB
02_biased_04.txt TLE 4410 ms 5600 KiB
02_biased_05.txt TLE 4410 ms 5548 KiB
02_biased_06.txt TLE 4410 ms 5500 KiB
02_biased_07.txt TLE 4410 ms 5476 KiB
02_biased_08.txt TLE 4410 ms 5372 KiB
02_biased_09.txt TLE 4410 ms 5476 KiB
03_border_00.txt TLE 4410 ms 5492 KiB
03_border_01.txt AC 30 ms 4164 KiB
03_border_02.txt AC 35 ms 4288 KiB
03_border_03.txt AC 2 ms 3708 KiB
03_border_04.txt TLE 4410 ms 5476 KiB
03_border_05.txt AC 30 ms 4116 KiB
03_border_06.txt AC 34 ms 4284 KiB
03_border_07.txt AC 2 ms 3700 KiB
03_border_08.txt AC 2 ms 3652 KiB
03_border_09.txt AC 2 ms 3804 KiB