結果

問題 No.2453 Seat Allocation
ユーザー SSRSSSRS
提出日時 2023-09-01 21:27:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 205,440 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2023-09-07 15:34:08
合計ジャッジ時間 6,181 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 219 ms
7,960 KB
testcase_06 AC 167 ms
4,380 KB
testcase_07 AC 36 ms
7,136 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 228 ms
7,356 KB
testcase_10 AC 233 ms
7,504 KB
testcase_11 AC 227 ms
7,968 KB
testcase_12 AC 163 ms
4,384 KB
testcase_13 AC 175 ms
4,376 KB
testcase_14 AC 162 ms
4,376 KB
testcase_15 AC 172 ms
4,380 KB
testcase_16 AC 157 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 175 ms
5,364 KB
testcase_19 AC 192 ms
7,236 KB
testcase_20 AC 77 ms
5,148 KB
testcase_21 AC 122 ms
4,380 KB
testcase_22 AC 172 ms
4,660 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
struct S{
  long long a, b, i;
  S(){
  }
  S(long long a, long long b, long long i): a(a), b(b), i(i){
  }
  bool operator <(S x) const {
    long long A = a * x.b;
    long long B = x.a * b;
    if (A < B){
      return true;
    } else if (A > B){
      return false;
    } else {
      return i > x.i;
    }
  }
};
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int> B(M);
  for (int i = 0; i < M; i++){
    cin >> B[i];
  }
  priority_queue<S> pq;
  vector<int> c(N, 0);
  for (int i = 0; i < N; i++){
    pq.push(S(A[i], B[0], i));
  }
  for (int i = 0; i < M; i++){
    S t = pq.top();
    pq.pop();
    cout << t.i + 1 << endl;
    int p = t.i;
    c[p]++;
    pq.push(S(A[p], B[c[p]], p));
  }
}
0