結果
| 問題 | No.808 Kaiten Sushi? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-24 00:01:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 925 bytes |
| 記録 | |
| コンパイル時間 | 742 ms |
| コンパイル使用メモリ | 69,536 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-24 00:01:56 |
| 合計ジャッジ時間 | 4,875 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d%d", &n, &l);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d", &p[i].first);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%d", &p[n + i].first);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 2 * 100010, INF = 0x3f3f3f3f;
int n, l;
PII p[N];
int main() {
// freopen("water.in", "r", stdin);
// freopen("water.out", "w", stdout);
scanf("%d%d", &n, &l);
for (int i = 0; i < n; ++i) {
scanf("%d", &p[i].first);
p[i].second = 1;
}
for (int i = 0; i < n; ++i) {
scanf("%d", &p[n + i].first);
p[n + i].second = -1;
}
sort(p, p + 2 * n);
LL ma = 0LL;
int cur = 0, mi = INF, last = -1;
for (int i = 0; i < 2 * n; ++i) {
cur += p[i].second;
if (cur >= ma) {
ma = cur;
last = i;
}
if (cur < mi) mi = cur;
}
int pos = (last + 1) % (2 * n);
LL ans = 1LL * (ma - mi - (ma > 0 ? 1 : 0)) * l + p[pos].first;
printf("%lld\n", ans);
return 0;
}