Submission #99922

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
999222019-03-08 18:55:55MohamedAhmed0K blocks (IZhO14_blocks)C++14
0 / 100
16 ms16896 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5 ;
const int MAXK = 1e2+5 ;
pair<long long , long long>dp[MAXN][MAXK] ;
int n , k ;
long long arr[MAXN] ;
int main()
{
scanf("%d %d" , &n , &k) ;
for(int i = 1 ; i <= n ; ++i)
scanf("%lld" , &arr[i]) ;
for(int i = 0 ; i <= n ; ++i)
{
for(int j = 0 ; j <= k ; ++j)
dp[i][j].first = dp[i][j].second = 1e18 ;
}
dp[0][0].first = dp[0][0].second = 0 ;
for(int i = 1 ; i <= n ; ++i)
{
for(int j = 1 ; j <= k ; ++j)
{
long long MAX = dp[i-1][j].second ;
long long a = arr[i] + dp[i-1][j-1].first ;
long long b = dp[i-1][j].first - MAX + max(MAX , arr[i]) ;
if(a <= b)
{
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

blocks.cpp: In function 'int main()':
blocks.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d" , &n , &k) ;
     ~~~~~^~~~~~~~~~~~~~~~~~~
blocks.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld" , &arr[i]) ;
         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...