Submission #624101

# Submission time Handle Problem Language Result Execution time Memory
624101 2022-08-07T09:02:48 Z Plurm Packing Biscuits (IOI20_biscuits) C++17
12 / 100
2 ms 340 KB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;

long long count_tastiness(long long x, vector<long long> a) {
  for (int i = 0; i < a.size(); i++) {
    if (a[i] <= 2ll)
      continue;
    if (a[i] % 2ll == 0ll) {
      long long d = (a[i] - 2ll) / 2ll;
      a[i] -= 2ll * d;
      if (i == a.size() - 1)
        a.push_back(d);
      else
        a[i + 1] += d;
    } else if (a[i] % 2ll == 1ll) {
      long long d = (a[i] - 1ll) / 2ll;
      a[i] -= 2ll * d;
      if (i == a.size() - 1)
        a.push_back(d);
      else
        a[i + 1] += d;
    }
  }
  int k = a.size();
  for (int i = k - 1; i > 0; i--) {
    if (a[i - 1] > 0ll) {
      a[i - 1] += a[i] * 2ll;
      a[i] = 0ll;
    }
  }
  long long ans = 1ll;
  for (int i = 0; i < k; i++)
    if (a[i])
      ans *= 1ll * (a[i] + 1ll);
  return ans;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:6:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |   for (int i = 0; i < a.size(); i++) {
      |                   ~~^~~~~~~~~~
biscuits.cpp:12:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |       if (i == a.size() - 1)
      |           ~~^~~~~~~~~~~~~~~
biscuits.cpp:19:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |       if (i == a.size() - 1)
      |           ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 228 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -