Submission #944501

# Submission time Handle Problem Language Result Execution time Memory
944501 2024-03-12T19:52:16 Z vjudge1 Rabbit Carrot (LMIO19_triusis) C++17
14 / 100
329 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef int INT;
#define int ll
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,pii> piiii;

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

vector<string>sub={"0","1"};

void dfs(int idx, int n) {
  if (idx==n) return;
  vector<string>ss;
  for (string s:sub) {
    s.push_back('0');
    ss.push_back(s);
    s.pop_back();
    s.push_back('1');
    ss.push_back(s);
  }
  sub=ss;
  dfs(idx+1,n);
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n,m;
  cin >> n >> m;
  vector<int>vec(n);
  for (int i=0; i<n; i++) {
    cin >> vec[i];
  }
  dfs(1,n);
  int mn=LLONG_MAX,cur=0;
  for (string s:sub) {
    vector<int>temp=vec;
    cur=0;
    int tot=0;
    // always go up by maximum amount (going down always works)
    bool b=true;
    for (int i=0; i<n; i++) {
      if (temp[i]>cur+m) {
        if (s[i]=='0') {
          b=false;
          break;
        }
      }
      if (s[i]=='1') {
        temp[i]=cur+m;
        tot++;
      }
      cur=temp[i];
    }
    if (b) {
      mn=min(mn,tot);
    }
    // cout << s << " " << cur << " " << tot << endl;
  }
  cout << mn << "\n";
}


/*

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 1 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 1 ms 452 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Runtime error 329 ms 262144 KB Execution killed with signal 9
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 329 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 329 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -