結果
| 問題 | 
                            No.2453 Seat Allocation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             umezo
                         | 
                    
| 提出日時 | 2023-09-05 04:45:32 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 61 ms / 2,000 ms | 
| コード長 | 1,035 bytes | 
| コンパイル時間 | 1,995 ms | 
| コンパイル使用メモリ | 201,196 KB | 
| 実行使用メモリ | 9,696 KB | 
| 最終ジャッジ日時 | 2025-06-20 01:49:13 | 
| 合計ジャッジ時間 | 3,759 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
struct frac{
  ll p,q;
  frac(ll P=0,ll Q=1):p(P),q(Q){}
  bool operator<(const frac &a)const{return p*a.q<a.p*q;}
  bool operator<=(const frac &a)const{return p*a.q<=a.p*q;}
  bool operator>(const frac &a)const{return p*a.q>a.p*q;}
  bool operator>=(const frac &a)const{return p*a.q>=a.p*q;}
  bool operator==(const frac &a)const{return p*a.q==a.p*q;}
  bool operator!=(const frac &a)const{return p*a.q!=a.p*q;}
};
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,m;
  cin>>n>>m;
  vector<ll> A(n),B(m);
  rep(i,n) cin>>A[i];
  rep(i,m) cin>>B[i];
  
  priority_queue<pair<pair<frac,ll>,ll>> que;
  rep(i,n) que.push({{{A[i],B[0]},-i},0});
  vector<ll> ANS(m);
  rep(i,m){
    auto t=que.top(); que.pop();
    ll a=-t.first.second,b=t.second;
    ANS[i]=a+1;
    b++;
    que.push({{{A[a],B[b]},-a},b});
  }
  rep(i,m) cout<<ANS[i]<<'\n';
  
  return 0;
}
            
            
            
        
            
umezo