結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2023-09-01 21:51:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 124 ms / 2,000 ms |
| コード長 | 901 bytes |
| コンパイル時間 | 3,662 ms |
| コンパイル使用メモリ | 225,300 KB |
| 実行使用メモリ | 8,828 KB |
| 最終ジャッジ日時 | 2025-06-20 01:44:11 |
| 合計ジャッジ時間 | 6,109 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
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;
}