Submission #1061156

#TimeUsernameProblemLanguageResultExecution timeMemory
1061156codefoxBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms348 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; #define ll long long ll delivery(int N,int K,int L,int positions[]) { deque<ll> first; deque<ll> second; for (int i = 0;i < N; i++) { if (positions[i]==0) continue; if (positions[i]<=L/2) first.push_back(positions[i]); else second.push_front(positions[i]); } ll sol = 0; while (first.size() >= K) { int t = K; sol += first[K-1]*2; while (t--) first.pop_front(); } while (second.size() >= K) { int t = K; sol += (L-second[second.size()-K])*2; while (t--) second.pop_back(); } if (first.size()==0 && second.size()==0) return sol; if (first.size() == 0) return sol+(L-second[0])*2; if (second.size()==0) return sol+first.back()*2; ll mn = 1e18; if (first.size()+second.size()<=K) mn = L; else { mn = min(mn, L+2*first[first.size()+second.size()-K]); mn = min(mn, L+2*second[second.size()-(first.size()+second.size()-K)]); } mn = min(mn, 2*(first.back()+L-second.front())); return sol+mn; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:25: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     while (first.size() >= K)
      |            ~~~~~~~~~~~~~^~~~
boxes.cpp:25:26: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while (second.size() >= K)
      |            ~~~~~~~~~~~~~~^~~~
boxes.cpp:35:35: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |     if (first.size()+second.size()<=K) mn = L;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
#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...