Submission #914232

#TimeUsernameProblemLanguageResultExecution timeMemory
914232ItamarBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
597 ms257208 KiB
using namespace std; #define ll long long #include <vector> #define vi vector<int> #include <algorithm> #define vll vector<ll> ll delivery(int N, int K, int L, int positions[]) { K = min(K, N); ll ans = 1e18; vi v1, v2; for (int i = 0; i < N; i++) { if (positions[i] <= L / 2)v1.push_back(positions[i]); else v2.push_back(L - positions[i]); } sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); int s1 = v1.size(), s2 = v2.size(); vll dp1(1+s1), dp2(1+s2); for (int i = 1; i <= min(s1,K); i++) { dp1[i] = 2*v1[i - 1]; } for (int i = K + 1; i <= s1; i++) { dp1[i] = 2*v1[i - 1] + dp1[i - K]; } for (int i = 1; i <= min(s2, K); i++) { dp2[i] = 2 * v2[i - 1]; } for (int i = K + 1; i <= s2; i++) { dp2[i] = 2 * v2[i - 1] + dp2[i - K]; } ans = dp1[s1] + dp2[s2]; for (int i = 0; i <= K; i++) { ans = min(ans,L+dp1[max(0,s1 - i)] + dp2[max(0,s2 - K + i)]); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:18: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   17 |  int s1 = v1.size(), s2 = v2.size();
      |           ~~~~~~~^~
boxes.cpp:17:34: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   17 |  int s1 = v1.size(), s2 = v2.size();
      |                           ~~~~~~~^~
#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...