Submission #305945

# Submission time Handle Problem Language Result Execution time Memory
305945 2020-09-24T06:35:32 Z llaki Packing Biscuits (IOI20_biscuits) C++17
0 / 100
1000 ms 16120 KB
#include <vector>
#include <map>
#include "biscuits.h"

long long count_tastiness(long long x, std::vector<long long> a) {
	std::map<long long, long long> freq;
	freq[a[0]] = 1;
	for (int pos = 0; pos < a.size() - 1; pos++) {
		std::map<long long, long long> map;
		for (const auto &[y, value]: freq) {
			long long val = a[pos + 1] + y / 2;
			long long oldFreq = 0;
			if (freq.find(val) != freq.end()) {
				oldFreq = map[val];
			}
			map[val] = oldFreq + freq[y];
			if (y >= x) {
				val = a[pos + 1] + (y - x) / 2;
				oldFreq = 0;
				if (freq.find(val) != freq.end()) {
					oldFreq = map[val];
				}
				map[val] = oldFreq + freq[y];
			}
		}
		freq = map;
	}
	long long ans = 0;
	for (const auto &[y, value]: freq) {
		ans += value * (y / x + 1);
	}
	return ans;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:8:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int pos = 0; pos < a.size() - 1; pos++) {
      |                    ~~~~^~~~~~~~~~~~~~
# 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 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Execution timed out 1086 ms 16120 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 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -