Submission #2120179
Source Code Expand
#include <iostream> #include <vector> #include <stdio.h> using namespace std; int n; int dp[2][101]; int ca[2][101]; int pick(int x, int y){ if (x==1 && y == n-1) return ca[x][y]; if (dp[x][y] != -1)return dp[x][y]; if (x != 1)dp[x][y]=pick(x+1, y); if (y+1 < n)dp[x][y] = max(dp[x][y], pick(x, y+1)); dp[x][y] += ca[x][y]; return dp[x][y]; } int main(int argc, char const *argv[]) { cin >> n; for (int i=0; i < n; i++) { dp[0][i] = -1; dp[1][i] = -1; cin >> ca[0][i]; } for (int i=0; i < n; i++) { cin >> ca[1][i]; } pick(0, 0); // printf("%d\n", pick(0, 0)); for (int i=0; i < n; i++){ printf("%d ", dp[0][i]); } printf("\n"); for (int i=0; i < n; i++){ printf("%d ", dp[1][i]); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Candies |
User | dasina |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 813 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample01.txt, sample02.txt, sample03.txt, sample04.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, sample01.txt, sample02.txt, sample03.txt, sample04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | WA | 1 ms | 256 KB |
02.txt | WA | 1 ms | 256 KB |
03.txt | WA | 1 ms | 256 KB |
04.txt | WA | 1 ms | 256 KB |
05.txt | WA | 1 ms | 256 KB |
06.txt | WA | 1 ms | 256 KB |
07.txt | WA | 1 ms | 256 KB |
08.txt | WA | 1 ms | 256 KB |
09.txt | WA | 1 ms | 256 KB |
10.txt | WA | 1 ms | 256 KB |
11.txt | WA | 1 ms | 256 KB |
12.txt | WA | 1 ms | 256 KB |
sample01.txt | WA | 1 ms | 256 KB |
sample02.txt | WA | 1 ms | 256 KB |
sample03.txt | WA | 1 ms | 256 KB |
sample04.txt | WA | 1 ms | 256 KB |