-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFARIDA.cpp
More file actions
40 lines (40 loc) · 813 Bytes
/
FARIDA.cpp
File metadata and controls
40 lines (40 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll t;
cin>>t;
ll k=1;
while(t--)
{
ll dp[10000];
dp[0]=0;
ll n;
cin>>n;
if(n==0)
{
cout<<"Case "<<k++<<": "<<0<<endl;
continue;
}
if(n==1)
{
ll x;
cin>>x;
cout<<"Case "<<k++<<": "<<x<<endl;
continue;
}
cin>>dp[1]>>dp[2];
dp[2]=max(dp[1],dp[2]);
for(int i=3;i<=n;i++)
{
ll x;
cin>>x;
dp[i]=max(x+dp[i-2],dp[i-1]);
}
cout<<"Case "<<k++<<": "<<dp[n]<<endl;
}
return 0;
}