Submission #219610

#TimeUsernameProblemLanguageResultExecution timeMemory
219610summitweiBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> #include <boxes.h> using namespace std; typedef vector<int> vi; typedef vector<pair<int, int> > vpii; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; typedef vector<ll> vll; #define INF 1000000000000000000LL #define MOD 1000000007LL #define EPSILON 0.00001 #define f first #define s second #define pb push_back #define mp make_pair #define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++) #define F0R(i, a) for (ll i=0; i<(signed)(a); i++) #define RFOR(i, a, b) for (ll i=(a); i >= b; i--) #define MN 10000005 int n, k; ll l; ll d[MN]; ll ps[MN]; ll rps[MN]; ll delivery(int n, int k, int l, int positions[]){ ::n = n; ::k = k; ::l = (ll)l; F0R(i, n) d[i] = positions[i]; F0R(i, n){ ps[i] = d[i]*2; if(i >= k){ ps[i] += ps[i-k]; } } RFOR(i, n-1, 0){ rps[i] = (l-d[i])*2; if(i+k < n){ rps[i] += rps[i+k]; } } ll ans = INF; F0R(i, n-1){ ans = min(ans, ps[i]+rps[i+1]); } if(k >= n) ans = min(ans, ::l); else{ F0R(i, n-k+1){ int lf = i-1, rt = i+k; ll res = ::l+(lf<0?0:ps[lf])+(rt>=n?0:rps[rt]); ans = min(ans, res); } } return ans; } /*int main(){ //ios_base::sync_with_stdio(false); //cin.tie(0); int N, K, L; cin >> N >> K >> L; int pos[N]; F0R(i, N) cin >> pos[i]; cout << delivery(N, K, L, pos) << "\n"; return 0; }*/

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:29:49: warning: declaration of 'l' shadows a global declaration [-Wshadow]
 ll delivery(int n, int k, int l, int positions[]){
                                                 ^
boxes.cpp:24:14: note: shadowed declaration is here
 int n, k; ll l;
              ^
boxes.cpp:29:49: warning: declaration of 'k' shadows a global declaration [-Wshadow]
 ll delivery(int n, int k, int l, int positions[]){
                                                 ^
boxes.cpp:24:8: note: shadowed declaration is here
 int n, k; ll l;
        ^
boxes.cpp:29:49: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 ll delivery(int n, int k, int l, int positions[]){
                                                 ^
boxes.cpp:24:5: note: shadowed declaration is here
 int n, k; ll l;
     ^
boxes.cpp:51:23: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
             int lf = i-1, rt = i+k;
                      ~^~
boxes.cpp:51:33: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
             int lf = i-1, rt = i+k;
                                ~^~
#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...