結果

問題 No.2453 Seat Allocation
ユーザー umezoumezo
提出日時 2023-09-05 04:45:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 1,035 bytes
コンパイル時間 2,342 ms
コンパイル使用メモリ 206,736 KB
実行使用メモリ 10,436 KB
最終ジャッジ日時 2023-09-07 15:38:57
合計ジャッジ時間 4,093 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 48 ms
9,216 KB
testcase_06 AC 21 ms
4,836 KB
testcase_07 AC 15 ms
8,244 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 62 ms
10,148 KB
testcase_10 AC 58 ms
9,128 KB
testcase_11 AC 60 ms
10,436 KB
testcase_12 AC 22 ms
4,580 KB
testcase_13 AC 26 ms
4,580 KB
testcase_14 AC 21 ms
4,652 KB
testcase_15 AC 31 ms
4,796 KB
testcase_16 AC 25 ms
4,836 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 41 ms
6,232 KB
testcase_19 AC 49 ms
9,180 KB
testcase_20 AC 21 ms
5,696 KB
testcase_21 AC 26 ms
4,780 KB
testcase_22 AC 37 ms
5,520 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0