結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-08-12 16:41:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,166 bytes |
| コンパイル時間 | 2,185 ms |
| コンパイル使用メモリ | 202,116 KB |
| 最終ジャッジ日時 | 2025-02-16 07:16:46 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct fraction{
ll p, q;
fraction(ll P=0, ll Q=1) : p(P), q(Q) {
if (Q < 0){
p *= -1;
q *= -1;
}
}
bool operator < (const fraction & other) const{
if (p < 0) return -p*other.q > -other.p*q;
return p*other.q < other.p*q;
}
bool operator == (const fraction & other) const{
return p*other.q == other.p*q;
}
bool operator > (const fraction & other) const{
if (p < 0) return -p*other.q < -other.p*q;
return p*other.q > other.p*q;
}
};
int main(){
ll N, M, x;
fraction p;
cin >> N >> M;
vector<ll> A(N), B(M+1), cnt(N);
for (int i=0; i<N; i++) cin >> A[i];
for (int i=0; i<M; i++) cin >> B[i];
priority_queue<pair<fraction, ll>> que;
for (int i=0; i<N; i++){
que.push({fraction(A[i], 1), -i});
}
while(M){
M--;
tie(p, x) = que.top();
que.pop();
cnt[-x]++;
que.push({fraction(A[-x], B[cnt[-x]]), x});
}
for (int i=0; i<N; i++) cout << cnt[i] << " ";
cout << endl;
return 0;
}
srjywrdnprkt