Submission #393207

#TimeUsernameProblemLanguageResultExecution timeMemory
393207peuchBoxes with souvenirs (IOI15_boxes)C++17
25 / 100
1 ms208 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<long long> esq, dir; long long n = N; long long k = K; long long l = L; for(int i = 0; i < n; i++){ if(p[i] <= L / 2) esq.push_back(2LL * (long long)p[i]); else if(p[i] > (L + 1) / 2) dir.push_back(2LL * l - 2LL * (long long)p[i]); } reverse(dir.begin(), dir.end()); for(int i = 0; i < esq.size(); i++) if(i >= k) esq[i] += esq[i - k]; for(int i = 0; i < dir.size(); i++) if(i >= k) dir[i] += dir[i - k]; long long ans = ((n + k - 1LL) / k) * l; long long cnt = n; int it1 = 0, it2 = 0; while(it1 != esq.size() || it2 != dir.size()){ if(it1 == esq.size()) it2++; else if(it2 == dir.size()) it1++; else if(esq[it1] < dir[it2]) it1++; else it2++; cnt--; long long aux = ((cnt + k - 1LL) / k) * l; if(it1 != 0) aux += esq[it1 - 1]; if(it2 != 0) aux += dir[it2 - 1]; ans = min(ans, aux); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i = 0; i < esq.size(); i++)
      |                 ~~^~~~~~~~~~~~
boxes.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i = 0; i < dir.size(); i++)
      |                 ~~^~~~~~~~~~~~
boxes.cpp:22:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  while(it1 != esq.size() || it2 != dir.size()){
      |        ~~~~^~~~~~~~~~~~~
boxes.cpp:22:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  while(it1 != esq.size() || it2 != dir.size()){
      |                             ~~~~^~~~~~~~~~~~~
boxes.cpp:23:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if(it1 == esq.size()) it2++;
      |      ~~~~^~~~~~~~~~~~~
boxes.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   else if(it2 == dir.size()) it1++;
      |           ~~~~^~~~~~~~~~~~~
#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...