답안 #405798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405798 2021-05-16T22:47:59 Z ly20 비스킷 담기 (IOI20_biscuits) C++17
0 / 100
1000 ms 332 KB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 40, INF = 1e9;

int mc[MAXN];

long long count_tastiness(long long x, vector<long long> a) {
	long long resp = 0;
	for(int j  = 0; j <= 100000; j++) {
        for(int i = 0; i < a.size(); i++) {
            mc[i] = a[i];
        }
        bool ok = true;
        for(int i = 17; i >= 0; i--) {
            long long rq = x;
            if((1LL << i) & j == 0) continue;
            for(int k = i; k >= 0; k--) {
                if(rq > INF) break;
                if(mc[i] <= rq) {
                    rq -= mc[i];
                    mc[i] = 0;
                }
                if(mc[i] > rq) {
                    rq = 0;
                    mc[i] -= rq;
                }
                rq *= 2;
            }
            if(rq != 0) ok = false;
        }
        if(ok) resp++;
	}
	return resp;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:12:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for(int i = 0; i < a.size(); i++) {
      |                        ~~^~~~~~~~~~
biscuits.cpp:18:31: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   18 |             if((1LL << i) & j == 0) continue;
      |                             ~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 358 ms 280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 313 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 300 ms 272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 358 ms 280 KB Output isn't correct
2 Halted 0 ms 0 KB -