Submission #393203

#TimeUsernameProblemLanguageResultExecution timeMemory
393203peuchBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms332 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 1e7 + 10; long long delivery(int N, int K, int L, int p[]) { vector<int> 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(2 * p[i]); else dir.push_back(2 * l - 2 * 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 - 1) / 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 = 0; if(it1 != 0) aux += esq[it1 - 1]; if(it2 != 0) aux += dir[it2 - 1]; aux += ((cnt + k - 1) / k) * l; ans = min(ans, aux); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:15:28: warning: conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} may change value [-Wconversion]
   15 |   else dir.push_back(2 * l - 2 * p[i]);
      |                      ~~~~~~^~~~~~~~~~
boxes.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i = 0; i < esq.size(); i++)
      |                 ~~^~~~~~~~~~~~
boxes.cpp:20:19: 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 = 0; i < dir.size(); i++)
      |                 ~~^~~~~~~~~~~~
boxes.cpp:25:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  while(it1 != esq.size() || it2 != dir.size()){
      |        ~~~~^~~~~~~~~~~~~
boxes.cpp:25:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  while(it1 != esq.size() || it2 != dir.size()){
      |                             ~~~~^~~~~~~~~~~~~
boxes.cpp:26:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   if(it1 == esq.size()) it2++;
      |      ~~~~^~~~~~~~~~~~~
boxes.cpp:27:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   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...