結果
| 問題 | 
                            No.2453 Seat Allocation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tnakao0123
                         | 
                    
| 提出日時 | 2023-09-11 15:15:32 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 982 bytes | 
| コンパイル時間 | 509 ms | 
| コンパイル使用メモリ | 56,608 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-29 05:23:14 | 
| 合計ジャッジ時間 | 3,265 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 WA * 1 | 
ソースコード
/* -*- coding: utf-8 -*-
 *
 * 2453.cc:  No.2453 Seat Allocation - yukicoder
 */
#include<cstdio>
#include<queue>
#include<algorithm>
 
using namespace std;
/* constant */
const int MAX_N = 100000;
const int MAX_M = 100000;
/* typedef */
struct Cand {
  double s;
  int i, j;
  Cand() {}
  Cand(double _s, int _i, int _j): s(_s), i(_i), j(_j) {}
  bool operator<(const Cand &c) const {
    return s < c.s || (s == c.s && i > c.i);
  }
};
/* global variables */
int as[MAX_N], bs[MAX_M];
/* subroutines */
/* main */
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  for (int i = 0; i < m; i++) scanf("%d", bs + i);
  priority_queue<Cand> q;
  for (int i = 0; i < n; i++)
    q.push(Cand((double)as[i] / bs[0], i, 0));
  for (int k = 0; k < m; k++) {
    auto u = q.top(); q.pop();
    printf("%d\n", u.i + 1);
    if (u.j + 1 < m)
      q.push(Cand((double)as[u.i] / bs[u.j + 1], u.i, u.j + 1));
  }
  return 0;
}
            
            
            
        
            
tnakao0123