結果
問題 | No.2453 Seat Allocation |
ユーザー | 👑 binap |
提出日時 | 2023-09-01 21:51:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 901 bytes |
コンパイル時間 | 3,951 ms |
コンパイル使用メモリ | 233,904 KB |
実行使用メモリ | 8,440 KB |
最終ジャッジ日時 | 2024-06-25 09:24:59 |
合計ジャッジ時間 | 6,497 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:35:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 35 | auto [rational_tmp, j] = pq.top(); pq.pop(); | ^
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using namespace atcoder; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; typedef vector<vector<int>> vvi; typedef vector<vector<long long>> vvl; typedef pair<int,int> P; typedef long double ld; struct Rational{ ll p, q; Rational(ll p, ll q) : p(p), q(q) {} bool operator<(const Rational& right) const{ return p * right.q < q * right.p; } }; int main(){ int n, m; cin >> n >> m; vl a(n), b(m); rep(i, n) cin >> a[i]; rep(i, m) cin >> b[i]; priority_queue<pair<Rational, ll>> pq; vi cnt(n); rep(i, n){ Rational rational(a[i], b[0]); pq.emplace(rational, -i); } rep(i, m){ auto [rational_tmp, j] = pq.top(); pq.pop(); j *= -1; cout << j + 1 << "\n"; cnt[j]++; Rational rational(a[j], b[cnt[j]]); pq.emplace(rational, -j); } return 0; }