結果
| 問題 |
No.808 Kaiten Sushi?
|
| コンテスト | |
| ユーザー |
noshi91
|
| 提出日時 | 2019-03-22 22:38:15 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 1,110 bytes |
| コンパイル時間 | 529 ms |
| コンパイル使用メモリ | 111,312 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 13:47:51 |
| 合計ジャッジ時間 | 2,691 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
コンパイルメッセージ
main.cpp:65:19: warning: format specifies type 'unsigned long long' but the argument has type 'u64' (aka 'unsigned long') [-Wformat]
65 | printf("%llu\n", ans);
| ~~~~ ^~~
| %lu
1 warning generated.
ソースコード
#include<cstddef>
#include<cstdint>
#include<cstdio>
#include<limits>
#include<vector>
using isize = std::ptrdiff_t;
using usize = std::size_t;
using u64 = std::uint_fast64_t;
template<int C,class T>
void scan(T &d) {
int c;
while (c = fgetc(stdin), c != C) {
d = d * 10 + c - '0';
}
}
int main() {
usize N = 0;
u64 L = 0;
scan<' '>(N);
scan<'\n'>(L);
std::vector<u64> x(N + 1), y(N + 1);
const usize li = N - 1;
for (usize i = 0;i != li;++i) {
scan<' '>(x[i]);
}
scan<'\n'>(x[li]);
x[N] = L;
for (usize i = 0;i != li;++i) {
scan<' '>(y[i]);
}
scan<'\n'>(y[li]);
y[N] = L;
isize count = 0, max = 0, min = 0;
auto xitr = x.cbegin(), yitr = y.cbegin();
u64 last;
for (usize i = 0;i != N * 2;++i) {
if (*xitr < *yitr) {
++count;
if (max <= count) {
max = count;
last = *yitr;
}
++xitr;
}
else {
--count;
if (count <= min) {
min = count;
}
++yitr;
}
}
const usize diff = max - min;
u64 ans;
if (max == static_cast<isize>(0)) {
ans = L*diff + y.front();
}
else {
ans = L*diff - (L - last);
}
printf("%llu\n", ans);
return 0;
}
noshi91