Submission #2542709
Source Code Expand
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n; int arr[2][101]; int dp[2][101]; int solve(int i,int j) { if(i>1 || j>=n) return 0; if(i==1 && j==n-1) return arr[i][j]; int &ret=dp[i][j]; if(ret!=-1) return ret; ret=0; return ret=max(arr[i][j]+solve(i,j+1),arr[i][j]+solve(i+1,j)); } int main() { scanf("%d",&n); for(int i=0;i<2;i++) for(int j=0;j<n;j++) scanf("%d",&arr[i][j]); memset(dp,-1,sizeof(dp)); printf("%d",solve(0,0)); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Candies |
User | AboveTheHorizon |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 603 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 128 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:26:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:29:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&arr[i][j]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 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 | AC | 1 ms | 128 KB |
02.txt | AC | 1 ms | 128 KB |
03.txt | AC | 1 ms | 128 KB |
04.txt | AC | 1 ms | 128 KB |
05.txt | AC | 1 ms | 128 KB |
06.txt | AC | 1 ms | 128 KB |
07.txt | AC | 1 ms | 128 KB |
08.txt | AC | 1 ms | 128 KB |
09.txt | AC | 1 ms | 128 KB |
10.txt | AC | 1 ms | 128 KB |
11.txt | AC | 1 ms | 128 KB |
12.txt | AC | 1 ms | 128 KB |
sample01.txt | AC | 1 ms | 128 KB |
sample02.txt | AC | 1 ms | 128 KB |
sample03.txt | AC | 0 ms | 128 KB |
sample04.txt | AC | 1 ms | 128 KB |