結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-01 22:15:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 141 ms / 2,000 ms |
| コード長 | 1,668 bytes |
| コンパイル時間 | 808 ms |
| コンパイル使用メモリ | 84,892 KB |
| 実行使用メモリ | 9,096 KB |
| 最終ジャッジ日時 | 2025-06-20 01:44:41 |
| 合計ジャッジ時間 | 3,250 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
const double eps=1e-12;
bool compare(tuple<ll,ll,int>&t1,tuple<ll,ll,int>&t2){
if(get<0>(t1)*get<1>(t2)>get<1>(t1)*get<0>(t2)){
return true;
}else if(get<0>(t1)*get<1>(t2)<get<1>(t1)*get<0>(t2)){
return false;
}else{
if(get<2>(t1)<get<2>(t2))return true;
else return false;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
vector<ll>A(N),B(M);
for(int i=0;i<N;i++)cin>>A[i];
for(int i=0;i<M;i++)cin>>B[i];
double ok=0,ng=2e9;
for(int i=0;i<100;i++){
double mid=(ok+ng)/2;
int cnt=0;
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
if(A[i]>B[j]*mid+eps){
cnt++;
}else{
break;
}
if(cnt>=M)break;
}
if(cnt>=M)break;
}
if(cnt>=M)ok=mid;
else ng=mid;
}
vector<tuple<ll,ll,int>>vp;
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
if(A[i]>B[j]*ok+eps){
vp.push_back(make_tuple(A[i],B[j],i));
}else{
break;
}
}
}
sort(all(vp),compare);
for(int i=0;i<M;i++){
cout<<get<2>(vp[i])+1<<"\n";
}
}