結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-09-11 15:20:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 2,000 ms |
| コード長 | 1,042 bytes |
| コンパイル時間 | 470 ms |
| コンパイル使用メモリ | 54,692 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 01:49:38 |
| 合計ジャッジ時間 | 2,552 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:42:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
42 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:43:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
43 | for (int i = 0; i < n; i++) scanf("%d", as + i);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:44:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
44 | for (int i = 0; i < m; i++) scanf("%d", bs + i);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 2453.cc: No.2453 Seat Allocation - yukicoder
*/
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 100000;
const int MAX_M = 100000;
/* typedef */
typedef long long ll;
struct Cand {
int i, j, a, b;
Cand() {}
Cand(int _i, int _j, int _a, int _b): i(_i), j(_j), a(_a), b(_b) {}
bool operator<(const Cand &c) const {
ll ab0 = (ll)a * c.b, ab1 = (ll)c.a * b;
return ab0 < ab1 || (ab0 == ab1 && i > c.i);
}
};
/* global variables */
int as[MAX_N], bs[MAX_M];
/* subroutines */
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", as + i);
for (int i = 0; i < m; i++) scanf("%d", bs + i);
priority_queue<Cand> q;
for (int i = 0; i < n; i++)
q.push(Cand(i, 0, as[i], bs[0]));
for (int k = 0; k < m; k++) {
auto u = q.top(); q.pop();
printf("%d\n", u.i + 1);
if (u.j + 1 < m)
q.push(Cand(u.i, u.j + 1, as[u.i], bs[u.j + 1]));
}
return 0;
}
tnakao0123