結果

問題 No.2453 Seat Allocation
ユーザー maeshunmaeshun
提出日時 2023-09-02 12:36:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 1,229 bytes
コンパイル時間 3,743 ms
コンパイル使用メモリ 232,028 KB
実行使用メモリ 10,376 KB
最終ジャッジ日時 2023-09-07 15:38:37
合計ジャッジ時間 6,394 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 105 ms
9,168 KB
testcase_06 AC 51 ms
4,376 KB
testcase_07 AC 25 ms
8,476 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 118 ms
10,376 KB
testcase_10 AC 116 ms
10,232 KB
testcase_11 AC 118 ms
8,984 KB
testcase_12 AC 50 ms
4,376 KB
testcase_13 AC 55 ms
4,376 KB
testcase_14 AC 49 ms
4,376 KB
testcase_15 AC 62 ms
4,376 KB
testcase_16 AC 46 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 78 ms
6,316 KB
testcase_19 AC 97 ms
9,868 KB
testcase_20 AC 40 ms
5,780 KB
testcase_21 AC 49 ms
4,640 KB
testcase_22 AC 71 ms
5,064 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:43:14: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   43 |         auto [f, idx] = pq.top();pq.pop();
      |              ^
main.cpp:44:14: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   44 |         auto [A, B, id] = f;
      |              ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

// p/q
struct fraction{
    ll p,q,id;
    fraction(ll P = 0, ll Q = 1, ll ID = 0): p(P), q(Q), id(ID){}
    bool operator<(const fraction &other)const{
        if(p*other.q==other.p*q){
            return id>other.id;
        }
        return p*other.q < other.p*q;
    }
};

int main()
{
    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<fraction, int>> pq;
    rep(i,n){
        pq.emplace(fraction{a[i], b[0], i},0);
    }
    for(int i=0;i<m;i++){
        auto [f, idx] = pq.top();pq.pop();
        auto [A, B, id] = f;
        cout << id+1 << "\n";
        if(idx+1<m){
            pq.emplace(fraction{a[id], b[idx+1], id}, idx+1);
        }
    }
    return 0;
}
0