제출 #1052527

#제출 시각아이디문제언어결과실행 시간메모리
1052527dozerPacking Biscuits (IOI20_biscuits)C++14
0 / 100
28 ms83072 KiB
#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define sp " "
#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second
#define pb push_back
#define ll long long
#define LL node * 2
#define RR node * 2 + 1
#define N 130
#define M 20005

const int modulo = 1e9 + 7;
const ll INF = 2e18 + 7;
 
 
ll arr[N], X;
ll dp[N][M], done[N][M];

int n;

ll f(int pos, ll sum){
	if (pos >= n) return 1;
	if (done[pos][sum]) return dp[pos][sum];
 
	ll curr_sum = sum + arr[pos];
	ll t1 = 0, t2 = 0;
	if (curr_sum >= X) t1 = f(pos + 1, (curr_sum - X) / 2);
	t2 = f(pos + 1, curr_sum / 2);
    done[pos][sum] = 1;
	return dp[pos][sum] = t1 + t2;
}
 
 
long long count_tastiness(long long x, vector<long long> a) {
	n = a.size();
	X = x;

    for (int i = 0; i < (int)a.size(); i++){
        if (a[i] > x + 1){
            if (i < n - 1) a[i + 1] += (a[i] - x) / 2;
            else a.pb((a[i] - x) / 2);
            a[i] = a[i] - ((a[i] - x) / 2) * 2;
        }
    }  

    n = a.size();


    for (int i = 0; i < n; i++)
        arr[i] = a[i];

	for (int i = 0; i < n; i++){
        for (int j = 0; j <= 2 * x; j++)
            done[i][j] = 0;
    }
 
 
	ll res = f(0, 0);
	return res;
}
 
/*
 
int main() {
	fileio();
	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;
}
*/

컴파일 시 표준 에러 (stderr) 메시지

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:55:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   55 |     for (int i = 0; i < n; i++)
      |     ^~~
biscuits.cpp:58:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   58 |  for (int i = 0; i < n; i++){
      |  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...