Submission #479989

# Submission time Handle Problem Language Result Execution time Memory
479989 2021-10-14T06:46:35 Z stefantaga Packing Biscuits (IOI20_biscuits) C++14
0 / 100
2 ms 460 KB
#include "biscuits.h"
#include <cassert>
#include <cstdio>

using namespace std;
long long sum=0,cop[65];
long long count_tastiness(long long x, std::vector<long long> a) {
    int k=a.size();
    long long p=1,suma=0,lim,t,ok1,nr=0,i;
    for (int i=0;i<k;i++)
    {
        suma=suma+p*a[i];
        p=p*2;
    }
    for (i=0;i<=60;i++)
    {
        if (a[i]>0)
        {
            nr++;
            a[i]--;
        }
        a[i+1]+=a[i]/2;
    }
    p=1;
    for (i=1;i<=nr;i++)
    {
        p=p*2;
    }
	return p;
}
#ifdef HOME
int main() {
	int q;
	assert(scanf("%d", &q) == 1);
	vector<int> k(q);
	vector<long long> x(q);
	vector<vector<long long>> a(q);
	vector<long long> results(q);
	for (int t = 0; t < q; t++) {
		assert(scanf("%d%lld", &k[t], &x[t]) == 2);
		a[t] = vector<long long>(k[t]);
		for (int i = 0; i < k[t]; i++) {
			assert(scanf("%lld", &a[t][i]) == 1);
		}
	}
	fclose(stdin);

	for (int t = 0; t < q; t++) {
		results[t] = count_tastiness(x[t], a[t]);
	}
	for (int t = 0; t < q; t++) {
		printf("%lld\n", results[t]);
	}
	fclose(stdout);
	return 0;
}
#endif // HOME

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:9:26: warning: unused variable 'lim' [-Wunused-variable]
    9 |     long long p=1,suma=0,lim,t,ok1,nr=0,i;
      |                          ^~~
biscuits.cpp:9:30: warning: unused variable 't' [-Wunused-variable]
    9 |     long long p=1,suma=0,lim,t,ok1,nr=0,i;
      |                              ^
biscuits.cpp:9:32: warning: unused variable 'ok1' [-Wunused-variable]
    9 |     long long p=1,suma=0,lim,t,ok1,nr=0,i;
      |                                ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -