Submission #303535

# Submission time Handle Problem Language Result Execution time Memory
303535 2020-09-20T11:39:54 Z user202729 Packing Biscuits (IOI20_biscuits) C++17
9 / 100
1000 ms 1051336 KB
// moreflags=grader.cpp
// naive solution (penultimate subtask)

#include "biscuits.h"
#include<cstdint>
#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){
		/*
		for(auto y: all) std::cout<<((y-s)>>std::min(i, 62))<<' ';
		std::cout<<"  << \n";
		*/

		// optional subtract x
		if(all[0]-x*std::round(std::pow(2., i))>=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;
		}

		if(i+1<(int)a.size())
			s-=a[i+1]<<(i+1);

		if(i==a.size()+62){ // +62 is actually a good idea, to avoid handling some special cases
			// the total complexity remains about small+2e5 for that subtask
			return (int)all.size();
		}
	}
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:34:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   if(i==a.size()+62){ // +62 is actually a good idea, to avoid handling some special cases
      |      ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1432 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 1144 KB Output is correct
5 Correct 1 ms 568 KB Output is correct
6 Correct 5 ms 2180 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 5 ms 2180 KB Output is correct
9 Correct 1 ms 540 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 2 ms 752 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 2 ms 1528 KB Output is correct
2 Execution timed out 1128 ms 1051336 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1135 ms 1051096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 937 ms 4140 KB Output is correct
2 Execution timed out 1092 ms 4868 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1432 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 1144 KB Output is correct
5 Correct 1 ms 568 KB Output is correct
6 Correct 5 ms 2180 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 5 ms 2180 KB Output is correct
9 Correct 1 ms 540 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 2 ms 752 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 1528 KB Output is correct
16 Execution timed out 1128 ms 1051336 KB Time limit exceeded
17 Halted 0 ms 0 KB -