Submission #67703

#TimeUsernameProblemLanguageResultExecution timeMemory
67703theknife2001Boxes with souvenirs (IOI15_boxes)C++17
10 / 100
2 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const int N=1e6+55; bool vis[N]; int n; long long delivery(int N, int k, int L, int p[]) { n=N; int x; int temp=0; bool q=0; long long ans=0; for(int i=0;i<n;i++) { x=k; temp=0; while(x--&&i<n) { if(p[i]==0) { vis[i]=1; i++; x++; } if(p[i]-temp<=L-(p[i]-temp)) { temp=p[i]; vis[i]=1; i++; } else break; } ans+=temp+min(temp,L-temp); } for(int i=n-1;i>=0&&vis[i]==0;i--) { x=k; temp=0; if(vis[i]) break; while(x--&&!vis[i]&&i<n) { temp=p[i]; i--; } ans+=L-temp+min(temp,L-temp); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:9:48: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 long long delivery(int N, int k, int L, int p[])
                                                ^
boxes.cpp:5:11: note: shadowed declaration is here
 const int N=1e6+55;
           ^
boxes.cpp:14:10: warning: unused variable 'q' [-Wunused-variable]
     bool q=0;
          ^
#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...