Submission #68406

#TimeUsernameProblemLanguageResultExecution timeMemory
68406zetapiBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
2 ms376 KiB
//#include "boxes.h" #include "bits/stdc++.h" using namespace std; #define pb push_back #define mp make_pair #define ll long long #define itr ::iterator const int MAX=1e5; ll N,K,L,sz,start[MAX],finish[MAX]; long long delivery(int N_,int K_, int L_,int P[]) { N=N_; K=K_; L=L_; for(int A=0;A<N;A+=K) { start[A/K]=P[A]; finish[A/K]=P[min(A+K-1,N-1)]; sz++; } if(K==N) { return min((ll)L,min((ll)2*P[N-1],(ll)2*(L-P[0]))); } ll res=0; for(int A=0;A<sz;A++) { //cout<<start[A]<<" "<<finish[A]<<"\n"; res+=min(2*finish[A],min(2*(L-start[A]),L)); } return res; } /*int main() { ios_base::sync_with_stdio(false); int P[]={1,2,5}; cout<<delivery(3,2,8,P)<<"\n"; return 0; }*/

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:22: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     for(int A=0;A<N;A+=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...