Submission #759079

#TimeUsernameProblemLanguageResultExecution timeMemory
759079BlagojBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
740 ms333032 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; #define ll long long int long long delivery(int N, int K, int L, int positions[]) { vector<int> v; for (int i = 0; i < N; i++) { if (positions[i] == 0) continue; v.push_back(positions[i]); } sort(v.begin(), v.end()); ll dpl[v.size()], dpr[v.size()]; for (int i = 0; i < min((int) v.size(), K); i++) dpl[i] = min(v[i] * 2, v[i] + L - v[i]); for (int i = K; i < v.size(); i++) dpl[i] = dpl[i - K] + min(v[i] * 2, v[i] + L - v[i]); int c = v.size() - 1; for (int i = 0; i < min((int) v.size(), K); i++) dpr[c - i] = min((L - v[c - i]) * 2, v[c - i] + L - v[c - i]); for (int i = K; i < v.size(); i++) dpr[c - i] = dpr[c - i + K] + min((L - v[c - i]) * 2, v[c - i] + L - v[c - i]); ll ans = min(dpr[0], dpl[v.size() - 1]); for (int i = 0; i < v.size() - 1; i++) ans = min(ans, dpl[i] + dpr[i + 1]); return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = K; i < v.size(); i++) dpl[i] = dpl[i - K] + min(v[i] * 2, v[i] + L - v[i]);
      |                     ~~^~~~~~~~~~
boxes.cpp:18:22: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   18 |     int c = v.size() - 1;
      |             ~~~~~~~~~^~~
boxes.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = K; i < v.size(); i++) dpr[c - i] = dpr[c - i + K] + min((L - v[c - i]) * 2, v[c - i] + L - v[c - i]);
      |                     ~~^~~~~~~~~~
boxes.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < v.size() - 1; i++) ans = min(ans, dpl[i] + dpr[i + 1]);
      |                     ~~^~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...