結果
| 問題 | 
                            No.2453 Seat Allocation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             srjywrdnprkt
                         | 
                    
| 提出日時 | 2024-06-25 11:31:29 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,004 bytes | 
| コンパイル時間 | 1,997 ms | 
| コンパイル使用メモリ | 202,244 KB | 
| 最終ジャッジ日時 | 2025-02-22 00:30:11 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / 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;
}
            
            
            
        
            
srjywrdnprkt