Submission #106258

# Submission time Handle Problem Language Result Execution time Memory
106258 2019-04-17T16:39:44 Z hamzqq9 Sličice (COCI19_slicice) C++14
90 / 90
115 ms 1404 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define inf 100000009
#define MOD 998244353
#define N 200005
#define M 2500005
#define LOG 20
#define KOK 300
#define EPS 0.0000001
using namespace std;

int main() {

	int n,m,k;

	scanf("%d %d %d",&n,&m,&k);

	vector<int> cur(n+1),b(m+1);

	for(int i=1;i<=n;i++) scanf("%d",&cur[i]);

	for(int i=0;i<=m;i++) scanf("%d",&b[i]);

	vector<vector<int>> dp(n+1,vector<int>(k+1,-inf));

	int ans=0;

	dp[0][0]=0;

	for(int i=1;i<=n;i++) {

		for(int j=0;j<=k;j++) {

			for(int l=0;l<=min(j,m-cur[i]);l++) {

				umax(dp[i][j],dp[i-1][j-l]+b[cur[i]+l]);

				umax(ans,dp[i][j]);

			}

		}

	}

	printf("%d",ans);

}

Compilation message

slicice.cpp: In function 'int main()':
slicice.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
slicice.cpp:35:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&cur[i]);
                        ~~~~~^~~~~~~~~~~~~~
slicice.cpp:37:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<=m;i++) scanf("%d",&b[i]);
                        ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 79 ms 1400 KB Output is correct
4 Correct 84 ms 1404 KB Output is correct
5 Correct 109 ms 1388 KB Output is correct
6 Correct 84 ms 1396 KB Output is correct
7 Correct 88 ms 1280 KB Output is correct
8 Correct 115 ms 1344 KB Output is correct
9 Correct 82 ms 1332 KB Output is correct
10 Correct 91 ms 1368 KB Output is correct