Submission #601970

#TimeUsernameProblemLanguageResultExecution timeMemory
601970FatihSolakCounting Mushrooms (IOI20_mushrooms)C++17
56.93 / 100
10 ms332 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
#define N 20000
using namespace std;

int count_mushrooms(int n){
	vector<int> a,b;
	a.push_back(0);
	int point  = 1;
	int cur = 0;
	while( (n-point + max(a.size(),b.size()) - 1) / max(a.size(),b.size()) + cur > 397 ){
		if(use_machine({0,point})){
			b.push_back(point);
		}
		else a.push_back(point);
		point++;
		cur++;
	}
	int ret = 0;
	int asz = a.size();
	int bsz = b.size();
	if(asz > bsz){
		for(int i = point;i<n;i+=asz){
			vector<int> nums;
			int cnt = 0;
			for(int j = i;j<min(n,i + asz);j++){
				nums.push_back(a[cnt++]);
				nums.push_back(j);
			}
			int sz = nums.size()/2;
			ret += sz - (use_machine(nums) + 1)/2;
		}
	}
	else{
		for(int i = point;i<n;i+=bsz){
			vector<int> nums;
			int cnt = 0;
			for(int j = i;j<min(n,i + bsz);j++){
				nums.push_back(b[cnt++]);
				nums.push_back(j);
			}
			int sz = nums.size()/2;
			ret += (use_machine(nums) + 1)/2;
		}
	}

	return ret + asz;
}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:42:8: warning: unused variable 'sz' [-Wunused-variable]
   42 |    int sz = nums.size()/2;
      |        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...