結果

問題 No.2453 Seat Allocation
ユーザー ochiaigawaochiaigawa
提出日時 2023-09-01 22:33:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,153 bytes
コンパイル時間 2,445 ms
コンパイル使用メモリ 207,784 KB
実行使用メモリ 814,920 KB
最終ジャッジ日時 2023-09-01 22:33:47
合計ジャッジ時間 5,013 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(M);
  vector<pair<int, int>> v(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < M; i++) {
    cin >> B[i];
  }
  double ok = 1e-10, ng = 1e10;
  for(int t = 0; t < 50; t++) {
    double m = (ok + ng) / 2;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
      if(cnt >= M) {
        break;
      }
      for(int j = 0; j < M; j++) {
        if((double) A[i] / B[j] >= m) {
          cnt++;
          if(cnt >= M) {
            break;
          }
        } else {
          break;
        }
      }
    }
    if(cnt >= M) {
      ok = m;
    } else {
      ng = m;
    }
  }
  cout << ok << endl;
  priority_queue<pair<double, int>> pq;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      if((long double) A[i] / B[j] >= ok) {
        pq.push(make_pair(A[i] / B[j], -i));
      } else {
        break;
      }
    }
  }
  for(int i = 0; i < M; i++) {
    auto [c, id] = pq.top();
    pq.pop();
    cout << 1 - id << '\n';
  }
  return 0;
}
0