結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
憩いの場
|
| 提出日時 | 2023-09-01 23:37:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 232 ms / 2,000 ms |
| コード長 | 1,268 bytes |
| コンパイル時間 | 609 ms |
| コンパイル使用メモリ | 74,648 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 01:47:56 |
| 合計ジャッジ時間 | 4,447 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
class Flaction
{
public:
long long a, b;
int id;
public:
Flaction( void ) = default;
Flaction( long long a, long long b, int id ) : a( a ), b( b ), id( id ) {};
int getID( void ) { return this->id; }
bool operator < ( const Flaction &flac ) const
{
if( this->a * flac.b == flac.a * this->b ) return this->id > flac.id;
else return this->a * flac.b < flac.a * this->b;
}
};
int main( void )
{
int N, M;
cin >> N >> M;
vector<int> A( N ), B( M );
for( int i = 0; i < N; i++ )
{
cin >> A[i];
}
for( int i = 0; i < M; i++ )
{
cin >> B[i];
}
priority_queue<Flaction> q;
vector<int> counter( N, 0 );
for( int i = 0; i < N; i++ )
{
q.push( Flaction( A[i], B[0], i ) );
}
Flaction max_people;
for( int k = 0; k < M; k++ )
{
max_people = q.top(), q.pop();
counter[max_people.getID()]++;
if( counter[max_people.getID()] != M )
{
q.push( Flaction( A[max_people.getID()], B[counter[max_people.getID()]], max_people.getID() ) );
}
cout << max_people.getID() + 1 << endl;
}
return 0;
}
憩いの場