Submission #303541

# Submission time Handle Problem Language Result Execution time Memory
303541 2020-09-20T11:45:56 Z user202729 Packing Biscuits (IOI20_biscuits) C++17
9 / 100
1000 ms 4920 KB
// moreflags=grader.cpp
// naive solution (penultimate subtask)
// ... I think that code is fast enough? No?

#include "biscuits.h"
#include<cstdint>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iostream>

long long count_tastiness(long long x, std::vector<long long> a) {
	std::vector<int64_t> all{a[0]};
	int64_t s=0;
	for(int i=0; i<(int)a.size()-1; ++i){
		/*
		for(auto y: all) std::cout<<((y-s)>>std::min(i, 62))<<' ';
		std::cout<<"  << \n";
		*/

		// optional subtract x
		if(all[0]-(double)x*std::round(std::pow(2., i))>=(double)s){
			// ^ check to avoid x<<i overflows int64_t (which is actually what happened to me in the contest)
			for(int n=(int)all.size(), index=0; index<n;++index)
				if(
						all[index]-(x<<i)
						>=s
				  )
					all.push_back(all[index]-(x<<i));
				else break;
		}

		s-=a[i+1]<<(i+1);
	}

	int curQuotient=0;
	int64_t result{};
	std::for_each(all.rbegin(), all.rend(), [&](auto y){
		auto const val=(y-s)>>(a.size()-1);
		while((curQuotient+1)*x<=val) ++curQuotient;
		result+=curQuotient+1;
	});
	return result;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 288 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Execution timed out 1095 ms 256 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 55 ms 384 KB Output is correct
2 Execution timed out 1043 ms 4920 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 288 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Execution timed out 1095 ms 256 KB Time limit exceeded
17 Halted 0 ms 0 KB -