Submission #605417

#TimeUsernameProblemLanguageResultExecution timeMemory
605417Sam_a17Packing Biscuits (IOI20_biscuits)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define sz(x) (int((x).size()))
#define len(x) (int)x.length()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(x) cout << #x << " " << x << endl;
#define uniq(x) x.resize(unique(all(x)) - x.begin());
 
#define pb push_back
#define ld long double
#define ll long long
 
// #include "mushrooms.h"
int use_machine(vector<int> m);
 
template<typename T>
void pr(vector<T>& a) {
  cerr << "arr" << " ";
  for(auto i: a) {
    cerr << i << " "; 
  } cerr << endl;
}


long long count_tastiness(long long x, std::vector<long long> a) {
  int k = sz(a);

  map<long long, long long> mp1, mp2;
  //
  mp1[0] = 1;
  //
  for(int i = 0; i < k; i++) {
    for(auto j: mp1) {
      mp2[(j.first + a[i]) / 2] += j.second;
      if(j.first + a[i] >= x) {
        mp2[(j.first + a[i] - x) / 2] += j.second;
      }
    } 
    
    mp1 = mp2;
    mp2.clear();
  }

  //
  long long answ = 0;
  for(auto i: mp1) {
    answ += i.second;
  }

	return answ;
}
 
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...