답안 #600942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
600942 2022-07-21T09:23:04 Z jjiangly Stove (JOI18_stove) C++14
20 / 100
73 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define siz(x) int(x.size())
#define ll long long
#define ar array
#define vt vector
#define inf INT_MAX
#define lnf LLONG_MAX

const int nxm = int(2e5) + 7;

int n, k, t[nxm];

namespace sub1 {
  void solve() {
    vt<bool> f(25, false);
    for (int i=0; i<n; ++i) {
      --t[i];
      f[t[i]]=true;
    }
    int ans=21;
    for (int mask=0; mask<(1<<20); ++mask) {
      int lbit=0;
      int ton=0;
      bool ok=true;
      for (int i=0; i<20; ++i) {
        if (mask>>i&1) {
          if (!lbit) {
            ++ton;
          }
        }
        if (!(mask>>i&1) && f[i]) {
          ok=false;
        }
        lbit=mask>>i&1;
      }
      if (ton<=k && ok) {
        ans=min(ans,__builtin_popcount(mask));
      }
    }
    cout<<ans<<"\n";
  }
};

int subtask() {
  if (n<=20) {
    return 1;
  } else if (n<=5000) {
    return 2;
  }
  return 3;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>n>>k;
  for (int i=0; i<n; ++i) {
    cin>>t[i];
  }
  if (subtask()==1) {
    sub1::solve();
  }

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 212 KB Output is correct
2 Correct 63 ms 212 KB Output is correct
3 Correct 59 ms 212 KB Output is correct
4 Correct 57 ms 212 KB Output is correct
5 Correct 60 ms 312 KB Output is correct
6 Correct 61 ms 312 KB Output is correct
7 Correct 66 ms 312 KB Output is correct
8 Correct 73 ms 312 KB Output is correct
9 Correct 58 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 212 KB Output is correct
2 Correct 63 ms 212 KB Output is correct
3 Correct 59 ms 212 KB Output is correct
4 Correct 57 ms 212 KB Output is correct
5 Correct 60 ms 312 KB Output is correct
6 Correct 61 ms 312 KB Output is correct
7 Correct 66 ms 312 KB Output is correct
8 Correct 73 ms 312 KB Output is correct
9 Correct 58 ms 212 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 212 KB Output is correct
2 Correct 63 ms 212 KB Output is correct
3 Correct 59 ms 212 KB Output is correct
4 Correct 57 ms 212 KB Output is correct
5 Correct 60 ms 312 KB Output is correct
6 Correct 61 ms 312 KB Output is correct
7 Correct 66 ms 312 KB Output is correct
8 Correct 73 ms 312 KB Output is correct
9 Correct 58 ms 212 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -