結果
問題 | No.561 東京と京都 |
ユーザー |
![]() |
提出日時 | 2018-06-05 17:52:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 716 ms |
コンパイル使用メモリ | 82,772 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 09:57:07 |
合計ジャッジ時間 | 1,532 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define p(s) cout<<(s)<<endl #define REP(i,n,N) for(int i=n;i<N;i++) #define RREP(i,n,N) for(int i=N-1;i>=n;i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define F first #define S second typedef long long ll; using namespace std; const ll mod = 1e9+7; ll N, D; ll dp[110][2]; ll T[110][2]; int main() { cin>>N>>D; REP(i,0,N){ cin>>T[i][0]>>T[i][1]; } dp[0][1] = -D; REP(i,0,N){ REP(j,0,2) { dp[i + 1][j] = max(dp[i+1][j], dp[i][j] + T[i][j]); dp[i + 1][1-j] = max(dp[i+1][1-j], dp[i][j] + T[i][1-j] - D); } } p(max(dp[N][0], dp[N][1])); return 0; }