Submission #1049737

# Submission time Handle Problem Language Result Execution time Memory
1049737 2024-08-09T04:34:30 Z vjudge1 Stove (JOI18_stove) C++17
20 / 100
210 ms 600 KB
#include <bits/stdc++.h>

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")

using namespace std;

#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define vc vector
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()

const int N = 1e5 + 5;
const int M = 1e5 + 5;
const int mod = 1e9 + 7;
const int block = 500;

int n, k, a[N];
bool col[N];

void solve() {
	cin >> n >> k;
    for ( int i = 1; i <= n; i++ ) {
        cin >> a[i];
        col[a[i]] = 1;
    }
    int res = 21;
    for ( int i = 0; i < (1<<20); i++ ) {
        vc <bool> used(21,0);
        int cnt = 0, ok = 1;
        for ( int j = 0; j < 20; j++ ) {
            if ( ( i >> j ) & 1 ) {
                used[j+1] = 1;
                cnt++;
            }
        }
        int k2 = 0;
        for ( int j = 1; j <= 20; j++ ) {
            if ( used[j] ) {
                if ( !used[j-1] ) k2++;
            }
            else {
                if ( col[j] ) ok = 0;
            }
        }
        if ( ok && k2 <= k ) res = min(res,cnt);
    }
    cout << res;
}

signed main() {
	speed;
	int tt;
	//cin >> tt;
    tt = 1;
	while ( tt-- ) {
		solve();
		cout << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 210 ms 344 KB Output is correct
2 Correct 205 ms 344 KB Output is correct
3 Correct 203 ms 348 KB Output is correct
4 Correct 201 ms 344 KB Output is correct
5 Correct 201 ms 348 KB Output is correct
6 Correct 201 ms 452 KB Output is correct
7 Correct 200 ms 348 KB Output is correct
8 Correct 201 ms 344 KB Output is correct
9 Correct 202 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 210 ms 344 KB Output is correct
2 Correct 205 ms 344 KB Output is correct
3 Correct 203 ms 348 KB Output is correct
4 Correct 201 ms 344 KB Output is correct
5 Correct 201 ms 348 KB Output is correct
6 Correct 201 ms 452 KB Output is correct
7 Correct 200 ms 348 KB Output is correct
8 Correct 201 ms 344 KB Output is correct
9 Correct 202 ms 344 KB Output is correct
10 Runtime error 1 ms 600 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 210 ms 344 KB Output is correct
2 Correct 205 ms 344 KB Output is correct
3 Correct 203 ms 348 KB Output is correct
4 Correct 201 ms 344 KB Output is correct
5 Correct 201 ms 348 KB Output is correct
6 Correct 201 ms 452 KB Output is correct
7 Correct 200 ms 348 KB Output is correct
8 Correct 201 ms 344 KB Output is correct
9 Correct 202 ms 344 KB Output is correct
10 Runtime error 1 ms 600 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -