Submission #619421

#TimeUsernameProblemLanguageResultExecution timeMemory
619421HazemBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
543 ms277488 KiB
#include <bits/stdc++.h> #define LL long long using namespace std; const LL LINF = 1e18; LL a[10000010],pr[10000010],su[10000010]; vector<LL>vec[2]; LL n,k,L1; long long delivery(int N, int K, int L, int p[]) { n = N,k = K; L1 = L; for(int i=1;i<=n;i++) a[i] = p[i-1]; for(int i=1;i<=n;i++) if(i<=k) pr[i] = a[i]*2; else pr[i] = pr[i-k] + a[i]*2; for(int i=n;i>=1;i--) if(n-i+1<=k) su[i] = (L-a[i])*2; else su[i] = su[i+k] + (L-a[i])*2; LL ans = min(pr[n],su[1]); for(int i=1;i<=n;i++){ ans = min(ans,pr[i-1]+su[i]); ans = min(ans,pr[i-1]+su[i+k]+L); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:27:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   27 |     for(int i=n;i>=1;i--)
      |               ^
#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...