結果
| 問題 |
No.1104 オンライン点呼
|
| ユーザー |
ngtkana
|
| 提出日時 | 2020-05-16 09:16:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,350 bytes |
| コンパイル時間 | 738 ms |
| コンパイル使用メモリ | 62,140 KB |
| 最終ジャッジ日時 | 2025-01-10 12:21:22 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:9:35: error: ‘numeric_limits’ in namespace ‘std’ does not name a template type
9 | template<class T> using numr=std::numeric_limits<T>;
| ^~~~~~~~~~~~~~
main.cpp:10:18: error: ‘int_least64_t’ in namespace ‘std’ does not name a type
10 | using i64 = std::int_least64_t;
| ^~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:32:5: error: ‘i64’ was not declared in this scope
32 | i64 k = read_int<i64>('\n', 0ll, 100'000'000ll);
| ^~~
main.cpp:34:8: error: expected ‘;’ before ‘inf’
34 | i64 inf = numr<i64>::max();
| ^~~~
| ;
main.cpp:35:20: error: template argument 2 is invalid
35 | std::vector<i64> a(n), b(n), time(n, inf);
| ^
main.cpp:35:42: error: ‘inf’ was not declared in this scope; did you mean ‘int’?
35 | std::vector<i64> a(n), b(n), time(n, inf);
| ^~~
| int
main.cpp:35:45: error: expression list treated as compound expression in initializer [-fpermissive]
35 | std::vector<i64> a(n), b(n), time(n, inf);
| ^
main.cpp:37:11: error: request for member ‘at’ in ‘a’, which is of non-class type ‘int’
37 | a.at(i) = read_int<i64>(i==n-1?'\n':' ', 0ll, 100'000'000ll);
| ^~
main.cpp:37:32: error: no matching function for call to ‘read_int<i64>(char, long long int, long long int)’
37 | a.at(i) = read_int<i64>(i==n-1?'\n':' ', 0ll, 100'000'000ll);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:15:3: note: candidate: ‘template<class T> T read_int(char, T, T)’
15 | T read_int(char end, T min, T max) {
| ^~~~~~~~
main.cpp:15:3: note: template argument deduction/substitution failed:
main.cpp:40:11: error: reques
ソースコード
/*
* 後ろから 2 つ目を見忘れる
*/
#include<cstddef>
#include<cstdio>
#include<cassert>
#include<iostream>
#include<vector>
template<class T> using numr=std::numeric_limits<T>;
using i64 = std::int_least64_t;
using usize = std::size_t;
auto cmn=[](auto&x,auto y){if(x>y){x=y;return true;}return false;};
template <class T>
T read_int(char end, T min, T max) {
T x = 0;
while (true) {
char c = std::getchar();
if (!std::isdigit(c)) {
assert(c==end);
break;
}
x = 10*x + c-'0';
assert(x<=100'000'000);
}
assert(min <= x && x <= max);
return x;
}
int main(){
usize n = read_int<usize>(' ', 1u, 100'000u);
i64 k = read_int<i64>('\n', 0ll, 100'000'000ll);
i64 inf = numr<i64>::max();
std::vector<i64> a(n), b(n), time(n, inf);
for (usize i=0; i<n; i++) {
a.at(i) = read_int<i64>(i==n-1?'\n':' ', 0ll, 100'000'000ll);
}
for (usize i=0; i<n; i++) {
b.at(i) = read_int<i64>(i==n-1?'\n':' ', 0ll, 100'000'000ll);
}
assert(std::getchar()==EOF);
time.at(0) = 0;
for (usize i=1; i<n; i++) {
time.at(i) = time.at(i-1)+a.at(i-1)+b.at(i);
if (1<i) cmn(time.at(i), time.at(i-2)+a.at(i-2)+b.at(i)+k);
}
std::cout << (n==1? i64{0} : std::max(time.at(n-2), time.at(n-1))) << '\n';
}
ngtkana