結果
問題 | No.2453 Seat Allocation |
ユーザー |
|
提出日時 | 2023-09-01 21:39:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 632 bytes |
コンパイル時間 | 610 ms |
コンパイル使用メモリ | 74,452 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 01:43:31 |
合計ジャッジ時間 | 2,635 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include<iostream> #include<queue> #include<cassert> using namespace std; struct Rat{ int a,b;//a/b bool operator<(const Rat&rhs)const{ return (long)a*rhs.b<(long)rhs.a*b;//a/b<rhs.a/rhs.b } }; int N,M; int A[1<<17],B[1<<17]; int idx[1<<17]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>M; for(int i=0;i<N;i++)cin>>A[i]; for(int i=0;i<M;i++)cin>>B[i]; priority_queue<pair<Rat,int> >Q; for(int i=0;i<N;i++)Q.push(make_pair(Rat{A[i],B[0]},-i)); for(int j=0;j<M;j++) { int i=-Q.top().second; Q.pop(); cout<<i+1<<"\n"; idx[i]++; if(idx[i]<M)Q.push(make_pair(Rat{A[i],B[idx[i]]},-i)); } }