結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
maeshun
|
| 提出日時 | 2023-09-02 12:36:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 118 ms / 2,000 ms |
| コード長 | 1,229 bytes |
| コンパイル時間 | 3,835 ms |
| コンパイル使用メモリ | 224,520 KB |
| 実行使用メモリ | 9,844 KB |
| 最終ジャッジ日時 | 2025-06-20 01:48:42 |
| 合計ジャッジ時間 | 6,159 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:43:14: warning: 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: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
44 | auto [A, B, id] = f;
| ^
ソースコード
#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;
}
maeshun