結果
問題 |
No.2453 Seat Allocation
|
ユーザー |
|
提出日時 | 2023-09-01 22:33:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,153 bytes |
コンパイル時間 | 2,098 ms |
コンパイル使用メモリ | 202,500 KB |
最終ジャッジ日時 | 2025-02-16 16:57:04 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 2 MLE * 1 -- * 19 |
ソースコード
#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; }