結果

問題 No.2453 Seat Allocation
ユーザー planes
提出日時 2023-09-01 22:43:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 946 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 173,044 KB
実行使用メモリ 8,732 KB
最終ジャッジ日時 2025-06-20 01:45:51
合計ジャッジ時間 5,435 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);

ll N,M;cin>>N>>M;
vector<ll> A(N),B(M);
for(ll i=0;i<N;i++) cin>>A[i];
for(ll i=0;i<M;i++) cin>>B[i];

priority_queue<tuple<ll,ll,ll>, vector<tuple<ll,ll,ll>>, function<bool(tuple<ll,ll,ll>,tuple<ll,ll,ll>)>>S(
        [](tuple<ll,ll,ll> a,tuple<ll,ll,ll> b){
          if(get<0>(a)*get<1>(b)!=get<1>(a)*get<0>(b))  return  get<0>(a)*get<1>(b)<get<1>(a)*get<0>(b);
          else return get<2>(a)>get<2>(b);
        }

    );

vector<ll> ind(N);
for(ll i=0;i<N;i++) {
  S.push(make_tuple(A[i],B[0],i));
}


for(ll i=0;i<M;i++) {
  auto v=S.top();
  S.pop();

ll now=get<2>(v);
  cout<<now+1<<endl;
  
  ind[now]++;
 if(ind[now]<M)  S.push(make_tuple(A[now],B[ind[now]],now));
}

}
  
0