結果
| 問題 |
No.1160 Strange Bowling
|
| ユーザー |
|
| 提出日時 | 2020-08-13 03:28:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 416 bytes |
| コンパイル時間 | 3,368 ms |
| コンパイル使用メモリ | 196,320 KB |
| 最終ジャッジ日時 | 2025-01-12 21:34:16 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | int n; scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:12:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | rep(i,n) scanf("%d%d",&p[i],&a[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int INF=1<<29;
int main(){
int n; scanf("%d",&n);
vector<int> p(n),a(n);
rep(i,n) scanf("%d%d",&p[i],&a[i]);
vector dp(n+1,vector(2,-INF));
dp[0][0]=0;
rep(i,n){
dp[i+1][0]=max(dp[i][0],dp[i][1]+p[i])+p[i];
dp[i+1][1]=max(dp[i][0],dp[i][1]+a[i])+a[i];
}
printf("%d\n",max(dp[n][0],dp[n][1]));
return 0;
}