Submission #18999775
Source Code Expand
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define xx first
#define yy second
#define ln 17
#define off 2
using namespace __gnu_pbds;
using namespace std ;
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const double EPS = 1e-9 , PI = acos(-1.0);
typedef long long T ;
#define maxn 500005
int a[505] ;
int dp[505][505] ;
int main()
{
int n ;
int cnt = 0 ;
scanf("%d",&n) ;
for(int i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;
for(int l=1 ; l<=n ; l++)
{
for(int i=1 ; i+l-1 <=n ; i++)
{
int j = i+l-1 ;
dp[i][j] = max( dp[i][j] , dp[i+1][j] ) ;
for(int x=i+1 ; x<=j ; x+=3 )
{
for(int y=x+1 ; y<=j ; y+=3)
{
dp[i][j] = max( dp[i][j] , a[i]+a[x]+a[y] + dp[i+1][x-1] + dp[x+1][y-1] + dp[y+1][j] ) ;
}
}
}
}
printf("%d\n",dp[1][n]) ;
return 0 ;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Three Coins |
| User | Arg_007 |
| Language | C++ (GCC 9.2.1) |
| Score | 800 |
| Code Size | 1430 Byte |
| Status | AC |
| Exec Time | 344 ms |
| Memory | 4820 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:39:9: warning: unused variable ‘cnt’ [-Wunused-variable]
39 | int cnt = 0 ;
| ^~~
./Main.cpp:41:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
41 | scanf("%d",&n) ;
| ~~~~~^~~~~~~~~
./Main.cpp:43:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
43 | for(int i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;
| ~~~~~^~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 800 / 800 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, example0.txt, example1.txt, example2.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 344 ms | 4816 KiB |
| 001.txt | AC | 341 ms | 4704 KiB |
| 002.txt | AC | 339 ms | 4784 KiB |
| 003.txt | AC | 342 ms | 4580 KiB |
| 004.txt | AC | 342 ms | 4620 KiB |
| 005.txt | AC | 338 ms | 4752 KiB |
| 006.txt | AC | 338 ms | 4592 KiB |
| 007.txt | AC | 340 ms | 4820 KiB |
| 008.txt | AC | 337 ms | 4808 KiB |
| 009.txt | AC | 340 ms | 4804 KiB |
| 010.txt | AC | 341 ms | 4616 KiB |
| 011.txt | AC | 337 ms | 4628 KiB |
| 012.txt | AC | 339 ms | 4704 KiB |
| 013.txt | AC | 341 ms | 4752 KiB |
| 014.txt | AC | 339 ms | 4572 KiB |
| 015.txt | AC | 341 ms | 4712 KiB |
| 016.txt | AC | 343 ms | 4672 KiB |
| 017.txt | AC | 340 ms | 4592 KiB |
| 018.txt | AC | 342 ms | 4668 KiB |
| 019.txt | AC | 339 ms | 4716 KiB |
| 020.txt | AC | 337 ms | 4580 KiB |
| 021.txt | AC | 340 ms | 4704 KiB |
| 022.txt | AC | 339 ms | 4752 KiB |
| 023.txt | AC | 337 ms | 4752 KiB |
| 024.txt | AC | 339 ms | 4716 KiB |
| 025.txt | AC | 337 ms | 4804 KiB |
| 026.txt | AC | 340 ms | 4708 KiB |
| 027.txt | AC | 342 ms | 4704 KiB |
| 028.txt | AC | 337 ms | 4628 KiB |
| 029.txt | AC | 339 ms | 4616 KiB |
| 030.txt | AC | 344 ms | 4672 KiB |
| 031.txt | AC | 338 ms | 4808 KiB |
| 032.txt | AC | 340 ms | 4712 KiB |
| 033.txt | AC | 340 ms | 4752 KiB |
| 034.txt | AC | 338 ms | 4820 KiB |
| 035.txt | AC | 339 ms | 4672 KiB |
| 036.txt | AC | 337 ms | 4716 KiB |
| 037.txt | AC | 342 ms | 4820 KiB |
| 038.txt | AC | 339 ms | 4704 KiB |
| 039.txt | AC | 337 ms | 4592 KiB |
| 040.txt | AC | 340 ms | 4816 KiB |
| 041.txt | AC | 339 ms | 4588 KiB |
| 042.txt | AC | 338 ms | 4808 KiB |
| 043.txt | AC | 337 ms | 4628 KiB |
| 044.txt | AC | 342 ms | 4716 KiB |
| 045.txt | AC | 337 ms | 4708 KiB |
| example0.txt | AC | 3 ms | 3604 KiB |
| example1.txt | AC | 2 ms | 3824 KiB |
| example2.txt | AC | 3 ms | 3744 KiB |