Submission #136145

# Submission time Handle Problem Language Result Execution time Memory
136145 2019-07-24T19:36:22 Z vardan__02 K blocks (IZhO14_blocks) C++14
32 / 100
1000 ms 504 KB
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define PB push_back
#define MP make_pair
ll n,m,i,j,ans=1000000007,k,a[105],x[105],p;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=n;i>=n-k+1;i--)
    x[i]=1;
    for(ll l=1;;l++)
    {
        m=0;p=0;
        for(i=1;i<=n;i++)
        {
            m=max(m,a[i]);
            if(x[i]==1)
            {
                p+=m;
                m=0;
            }
        }
        ans=min(ans,p);
        if(!next_permutation(x+1,x+n))
            break;
    }
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 898 ms 504 KB Output is correct
14 Correct 898 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 903 ms 388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 10 ms 376 KB Output is correct
15 Correct 9 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 10 ms 376 KB Output is correct
19 Correct 3 ms 380 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -