# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
100809 |
2019-03-14T15:15:43 Z |
Scayre |
K blocks (IZhO14_blocks) |
C++14 |
|
1000 ms |
1708 KB |
///////////////////////////
// INFO //
// //
// Handle -> Scayre //
// //
// Template vers. 1.7 //
// //
// It'll be accepted //
// //
///////////////////////////
//████╗████████╗██╗███████╗══███╗═══███╗████████╗════//
//═██╔╝═══██╔══╝╚█║██╔════╝══████╗═████║██╔═════╝═══//
//═██║════██║════╚╝███████╗══██╔████╔██║█████╗══════//
//═██║════██║══════╚════██║══██║╚██╔╝██║██╔══╝══════//
//████╗═══██║══════███████║══██║═╚═╝═██║███████╗═════//
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <complex>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
#define f first
#define s second
#define inf (int)1e9 + 7
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp(x,y) make_pair(x,y)
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
#define pb push_back
#define ppb pop_back
#define bitcoin __builtin_popcount
#define endl "\n"
#define in(x) insert(x)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define pw2(x) (1<<x) //2^x
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
#define sqr(x) ((x) * 1ll * (x))
#define UpdateRandom srand (time(NULL));
using namespace std;
const int N = (int)1e5 + 7, MOD = (int)1e9 + 7;
int n,k;
int a[N];
bool was[N][102];
ll dp[N][102];
ll t[4*N];
void build(int v,int l,int r){
if(l==r){
t[v]=a[l];
return;
}
int md=(l+r)/2;
build(v+v,l,md);
build(v+v+1,md+1,r);
t[v]=max(t[v+v],t[v+v+1]);
}
ll mx(int v,int l,int r,int L,int R){
if(r<L || l>R){
return 0;
}
if(L<=l && R>=r){
return t[v];
}
int md=(l+r)/2;
return max(mx(v+v,l,md,L,R),mx(v+v+1,md+1,r,L,R));
}
ll calc(int x,int y=0){
if(y==k-1){
return mx(1,1,n,x,n);
}
if(dp[x][y]!=0)return dp[x][y];
int mx=0;
dp[x][y]=inf;
//cout << n-k+y << endl;
for(int i=x;i<=((n-k+1)+y);i++){
mx=max(mx,a[i]);
dp[x][y]=min(dp[x][y],calc(i+1,y+1)+mx);
}
return dp[x][y];
}
int main(){
#ifdef IOI2019
freopen ("in.txt", "r", stdin);
#endif
NFS
cin >> n >> k;
for(int i=1;i<=n;i++){
cin >> a[i];
}
build(1,1,n);
cout << calc(1) << endl;
#ifdef IOI2019
cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl;
#endif
ioi
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
428 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
3 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
512 KB |
Output is correct |
16 |
Correct |
2 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
1708 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |