Submission #897631

#TimeUsernameProblemLanguageResultExecution timeMemory
897631oblantisBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms512 KiB
#include "boxes.h" #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, int> pdi; const ll inf = 1e18 + 10000; const int mod = 1e9+7; const int maxn = 1e5 + 12; long long delivery(int n, int k, int l, int p[]) { deque<int> ls, mr; for(int i = 0; i < n; i++){ if(p[i] <= l / 2)ls.pb(p[i]); else mr.pb(p[i]); } ll ret = 0; while(ls.size() >= k){ int x = ls.back(); for(int i = 0; i < k; i++){ ls.pop_back(); } ret += x * 2; } while(mr.size() >= k){ int x = mr.front(); for(int i = 0; i < k; i++){ mr.pop_front(); } ret += (l - x) * 2; } if(mr.empty() && ls.empty())return ret; else if(mr.empty() && !ls.empty())ret += ls.back() * 2; else if(!mr.empty() && ls.empty())ret += (l - mr.front()) * 2; else if(mr.size() + ls.size() > k)ret += ls.back() * 2 + (l - mr.front()) * 2; else ret += min(l, ls.back() * 2 + (l - mr.front()) * 2); return ret; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |  while(ls.size() >= k){
      |        ~~~~~~~~~~^~~~
boxes.cpp:35:18: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |  while(mr.size() >= k){
      |        ~~~~~~~~~~^~~~
boxes.cpp:45:32: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |  else if(mr.size() + ls.size() > k)ret += ls.back() * 2 + (l - mr.front()) * 2;
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~
#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...