Submission #855690

# Submission time Handle Problem Language Result Execution time Memory
855690 2023-10-01T16:29:53 Z TimDee Peru (RMI20_peru) C++17
Compilation error
0 ms 0 KB
//  Esti <3

//\
     šťastia pre nás :)
//   you're already the best
//             _
//   ^ ^      //
// >(O_O)<___//
//   \ __ __  \
//    \\ \\ \\\\
 
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3","unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")

using ll = long long;
#define int long long
#define forn(i,n) for(int i=0; i<(n); ++i)
#define pb push_back
#define pi pair<int,int>
#define f first
#define s second 
#define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e18;
const ll mod = 1e9+7;//998244853;
 
// \
\
:smiling_face_with_3_hearts: :smiling_face_with_3_hearts:  :smiling_face_with_3_hearts:  
 
//vidime sa veľmi skoro, moje slnko

void solve() {
	
	int n,k; cin>>n>>k;
	vii(a,n);
	vector<int> dp(n+1,inf);
	dp[0]=0;
	for (int i=1; i<=n; ++i) {
		int m=0;
		for(int j=i-1; j>=0 && i-j<=k; --j) {
			m=max(m,a[j]);
			dp[i]=min(dp[i],dp[j]+m);
		}
	}

	int ans=0, p=1;
	for (int i=n; i; --i) {
		dp[i]%=mod;
		ans=(ans+p*dp[i])%mod;
		p=(p*23)%mod;
	}
	cout<<ans<<'\n';

}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t=1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Compilation message

peru.cpp:3:1: warning: multi-line comment [-Wcomment]
    3 | //\
      | ^
peru.cpp:9:1: warning: multi-line comment [-Wcomment]
    9 | //   \ __ __  \
      | ^
peru.cpp:36:1: warning: multi-line comment [-Wcomment]
   36 | // \
      | ^
/usr/bin/ld: /tmp/ccAEVY5g.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqdpn7e.o:peru.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccAEVY5g.o: in function `main':
grader.cpp:(.text.startup+0x144): undefined reference to `solve(int, int, int*)'
collect2: error: ld returned 1 exit status