結果
問題 | No.2453 Seat Allocation |
ユーザー | srjywrdnprkt |
提出日時 | 2024-06-25 11:31:29 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,004 bytes |
コンパイル時間 | 2,293 ms |
コンパイル使用メモリ | 211,820 KB |
実行使用メモリ | 7,696 KB |
最終ジャッジ日時 | 2024-06-25 11:31:37 |
合計ジャッジ時間 | 4,191 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<double, int>; // {score, party} int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector<ll> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } vector<ll> B(M); for (int j = 0; j < M; ++j) { cin >> B[j]; } priority_queue<P> pq; vector<int> index(N, 0); for (int i = 0; i < N; ++i) { double initial_score = static_cast<double>(B[0]) / A[i]; pq.push({initial_score, i}); } vector<int> result; for (int k = 0; k < M; ++k) { auto [score, party] = pq.top(); pq.pop(); result.push_back(party + 1); if (++index[party] < M) { double next_score = static_cast<double>(B[index[party]]) / A[party]; pq.push({next_score, party}); } } for (int k = 0; k < M; ++k) { cout << result[k] << "\n"; } return 0; }