Submission #768922

#TimeUsernameProblemLanguageResultExecution timeMemory
768922caganyanmazBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define DEBUGGING #define f first #define s second #define int int64_t #ifdef DEBUGGING #define debug(x) cout << (#x) << ": " << (x) << "\n"; #else #define debug(x) 42 #endif using namespace std; constexpr static int MXSIZE = 1e7 + 2; int left_dp[MXSIZE]; int right_dp[MXSIZE]; vector<int> left_val; vector<int> right_val; int mid = 0; int delivery(int32_t N, int32_t K, int32_t L, int32_t p[]) { for (int i = 0; i < N; i++) if (p[i] < L / 2) left_val.pb(p[i]); else if (p[i] > L / 2) right_val.pb(-p[i]); else mid++; sort(left_val.begin(), left_val.end()); sort(right_val.begin(), right_val.end()); for (int i = 1; i <= left_val.size(); i++) { if (i - K >= 0) left_dp[i] = left_dp[i-K]; left_dp[i] += left_val[i-1] * 2; } for (int i = 1; i <= right_val.size(); i++) { if (i - K >= 0) right_dp[i] = right_dp[i-K]; right_dp[i] += (L + right_val[i-1]) * 2; } int res = left_dp[left_val.size()] + right_dp[right_val.size()] + (mid/K) * L; if (mid%K) res += L; for (int j = 1; j <= 4; j++) { int lo = K * j - (mid % K); for (int i = 0; i <= lo; i++) res = min(res, left_dp[left_val.size()-i] + right_dp[right_val.size()-lo+i] + ((mid+lo)/K) * L); } return res;

Compilation message (stderr)

boxes.cpp: In function 'int64_t delivery(int32_t, int32_t, int32_t, int32_t*)':
boxes.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (int i = 1; i <= left_val.size(); i++)
      |                  ~~^~~~~~~~~~~~~~~~~~
boxes.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for (int i = 1; i <= right_val.size(); i++)
      |                  ~~^~~~~~~~~~~~~~~~~~~
boxes.cpp:53:12: error: expected '}' at end of input
   53 |  return res;
      |            ^
boxes.cpp:22:1: note: to match this '{'
   22 | {
      | ^