結果

問題 No.2453 Seat Allocation
ユーザー hiro71687k
提出日時 2023-09-01 21:52:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 1,366 bytes
コンパイル時間 4,105 ms
コンパイル使用メモリ 260,476 KB
実行使用メモリ 16,836 KB
最終ジャッジ日時 2025-06-20 01:44:17
合計ジャッジ時間 8,413 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ld inf=10000999999999900;
pair<ld,pair<ll,ll>> op(pair<ld,pair<ll,ll>> a,pair<ld,pair<ll,ll>> b){
    if (a.first>b.first)
    {
        return a;
    }else if (a.first==b.first)
    {
        if (a.second.first<b.second.first)
        {
            return a;
        }else{
            return b;
        }
    }else{
        return b;
    }
}
pair<ld,pair<ll,ll>>e(){
    return {-inf,{-inf,-inf}};
}
int main(){
    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];
    }
    sort(b.begin(),b.end());
    b.push_back(inf);
    vector<pair<ld,pair<ll,ll>>>p(n);
    for (ll i = 0; i < n; i++)
    {
        p[i]={(ld)((ld)a[i]/(ld)b[0]),{i,0}};
    }
    segtree<pair<ld,pair<ll,ll>>,op,e>seg(p);
    vector<ll>ans(m);
    for (ll i = 0; i < m; i++)
    {
        pair<ld,pair<ll,ll>>pp=seg.all_prod();
        ans[i]=pp.second.first+1;
        pp.second.second++;
        pp.first=(ld)((ld)a[pp.second.first]/(ld)b[pp.second.second]);
        seg.set(pp.second.first,pp);
    }
    for (ll i = 0; i < m; i++)
    {
        cout << ans[i] << endl;
    }
    
}
0