Submission #604264

#TimeUsernameProblemLanguageResultExecution timeMemory
604264wiwihoBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
693 ms295760 KiB
#include "boxes.h" #include <bits/stdc++.h> #define iter(a) a.begin(), a.end() #define lsort(a) sort(iter(a)) #define gsort(a) sort(iter(a), greater<>()) #define eb emplace_back #define ef emplace_front #define pob pop_back() #define pof pop_front() #define mp make_pair #define F first #define S second #define uni(a) a.resize(unique(iter(a)) - a.begin()) #define printv(a, b){ \ for(auto pv : a) b << pv << " "; \ b << "\n"; \ } using namespace std; typedef long long ll; typedef long double ld; using pii = pair<int, int>; using pll = pair<ll, ll>; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } ll delivery(int n, int K, int _L, int _p[]){ ll len = _L; vector<ll> p; p.eb(0); for(int i = 0; i < n; i++){ if(_p[i] != 0) p.eb(_p[i]); } p.eb(len); n = p.size(); vector<ll> ans(n); { vector<ll> sum(K); for(int i = 0; i < n; i++){ sum[i % K] += p[i] + min(p[i], len - p[i]); ans[i] += sum[i % K]; } } { vector<ll> sum(K); for(int i = n - 1; i >= 0; i--){ sum[i % K] += (len - p[i]) + min(p[i], len - p[i]); ans[(i - 1 + n) % n] += sum[i % K]; } } return *min_element(iter(ans)); }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:44:15: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   44 |     n = p.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...