結果
問題 |
No.818 Dinner time
|
ユーザー |
|
提出日時 | 2019-04-20 10:51:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 30,208 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 23:34:53 |
合計ジャッジ時間 | 1,578 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%lld %lld", &N, &M); | ~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%lld %lld", &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%lld %lld", &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<math.h> #define int long long #define max(a,b) (a>b?a:b) // int max(int a, int b){ // return a>b?a:b; // } signed main(){ int N, M, hoge[2][2] = {}, x, ans = 0, a, b, num; scanf("%lld %lld", &N, &M); scanf("%lld %lld", &a, &b); x = max(b,a*(M-1)+max(a,b)); for(int i = 1; i < N; i++){ scanf("%lld %lld", &a, &b); num = max(a,b); hoge[(i+1)%2][1] = max(b,a*(M-1)+num)+hoge[i%2][1]; hoge[(i+1)%2][0] = max(hoge[i%2][0],hoge[i%2][1]) +num; ans = max(ans,max(hoge[(i+1)%2][0],hoge[(i+1)%2][1])); } ans += x; printf("%lld\n",ans); return 0; }