GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CompetitiveProgramming/Topcoder/SRM778-D1-600.cpp at master · danh2006/CompetitiveProgramming

Expand file tree

/

SRM778-D1-600.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
43 lines (41 loc) · 1.01 KB
/

SRM778-D1-600.cpp

Copy path

File metadata and controls

43 lines (41 loc) · 1.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
41
42
43
#include <bits/stdc++.h>
using namespace std;
#define ll long long
class CollectingCoins {
public:
vector<int> v, d;
vector<ll> a;
vector<ll> f(int m, int k) {
if((m+k)%2==1&&m) {
vector<ll> b=f(m-1, k);
b.push_back(0);
for(int i=1; i<=k; ++i)
b.back()=max(b[2*k-i]+a[i], b.back());
return vector<ll>(b.begin()+1, b.end());
} else if((m+k)%2==0&&m>=k) {
vector<ll> b=f((m+k)/2-k, k), c(2*k-1);
for(int i=1; i<k; ++i)
for(int j=0; j<k; ++j)
c[i-1]=max(b[k-1-j]+b[i-1+j], c[i-1]);
for(int i=k; i<2*k; ++i)
for(int j=1; j<=k; ++j)
c[i-1]=max(b[2*k-1-j]+b[i-k+j-1], c[i-1]);
return c;
} else {
a=vector<ll>(m+2*k);
for(int i=1; i<a.size(); ++i) {
if(i<=k)
for(int j=0; j<v.size(); ++j)
a[i]+=(i-1-(i-1)/d[j])*v[j];
for(int j=1; j<min(k+1, i); ++j)
a[i]=max(a[j]+a[i-j], a[i]);
}
return vector<ll>(a.begin()+m+1, a.end());
}
}
ll maxValue(int m, int k, vector<int> v, vector<int> d) {
this->v=v;
this->d=d;
return f(m+1, k)[0];
}
};
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.