結果

問題 No.1104 オンライン点呼
ユーザー ngtkanangtkana
提出日時 2020-05-16 09:12:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,181 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 64,340 KB
最終ジャッジ日時 2024-04-27 03:11:37
合計ジャッジ時間 1,233 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:6:35: error: 'numeric_limits' in namespace 'std' does not name a template type
    6 | template<class T> using numr=std::numeric_limits<T>;
      |                                   ^~~~~~~~~~~~~~
main.cpp: In function 'int main()':
main.cpp:30:15: error: 'numr' was not declared in this scope
   30 |     i64 inf = numr<i64>::max();
      |               ^~~~
main.cpp:30:23: error: expected primary-expression before '>' token
   30 |     i64 inf = numr<i64>::max();
      |                       ^
main.cpp:30:26: error: '::max' has not been declared; did you mean 'std::max'?
   30 |     i64 inf = numr<i64>::max();
      |                          ^~~
      |                          std::max
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39,
                 from main.cpp:4:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~

ソースコード

diff #

#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 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);
    }
    return x;
}

int main(){
    usize n = read_int<usize>(' ');
    i64 k = read_int<i64>('\n');

    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':' ');
    }
    for (usize i=0; i<n; i++) {
        b.at(i) = read_int<i64>(i==n-1?'\n':' ');
    }
    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';
}
0