ログインしてください。
Submission #18202154
Source Code Expand
#include <bits/stdc++.h>
#define ll long long
#define nl "\n"
#define ii pair<int, int>
#define MOD 10000007
#define inf 1 << 30
using namespace std;
const int M = 1e5 + 7;
int dp[M][3], a[M][3], n;
int tc;
void solve()
{
cin >> n;
for(int i = 0; i < n; i++){
for(int j = 0; j < 3; j++) cin >> a[i][j];
}
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for(int i = 1; i < n; i++){
for(int j = 0; j < 3; j++){
for(int k = 0; k < 3; k++){
if(k == j) continue;
dp[i][j] = max(dp[i - 1][k] + a[i][j], dp[i][j]);
}
}
}
int res = 0;
for(int i = 0; i < 3; i++) res = max(res, dp[n - 1][i]);
cout << res << nl;
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(0);
int t = 1;
//cin >> t;
while (t--)
{
solve();
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Vacation |
| User | Imtiaz_Riton |
| Language | C++ (GCC 9.2.1) |
| Score | 100 |
| Code Size | 979 Byte |
| Status | AC |
| Exec Time | 34 ms |
| Memory | 6004 KiB |
Judge Result
| Set Name | All | ||
|---|---|---|---|
| Score / Max Score | 100 / 100 | ||
| Status |
|
| Set Name | Test Cases |
|---|---|
| All | 0_00, 0_01, 0_02, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_00 | AC | 5 ms | 3576 KiB |
| 0_01 | AC | 3 ms | 3620 KiB |
| 0_02 | AC | 3 ms | 3548 KiB |
| 1_00 | AC | 2 ms | 3532 KiB |
| 1_01 | AC | 34 ms | 6004 KiB |
| 1_02 | AC | 30 ms | 5860 KiB |
| 1_03 | AC | 29 ms | 5816 KiB |
| 1_04 | AC | 26 ms | 5816 KiB |
| 1_05 | AC | 32 ms | 5928 KiB |
| 1_06 | AC | 31 ms | 5960 KiB |
| 1_07 | AC | 26 ms | 5860 KiB |
| 1_08 | AC | 29 ms | 5904 KiB |
| 1_09 | AC | 31 ms | 5868 KiB |