Submission #1052505

#TimeUsernameProblemLanguageResultExecution timeMemory
1052505modwweBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
347 ms372048 KiB
//https://www.instagram.com/_modwwe/ //#pragma GCC optimize("Ofast,unroll-loops") #include "boxes.h" #include<bits/stdc++.h> #define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; void phongbeo(); const ll inf=1e18; const int mod2=1e9+7; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { ll a; ll b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; ll n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid; int i,s10,s12; int kk; int el=29; ll a[10000002]; ll dp[10000002]; ll dp2[10000002]; long long delivery(int N, int K, int L, int p[]) { n=N; k=K; m=L; for(int i=1; i<=N; i++) { a[++dem]=p[i-1]; if(a[dem]==0) dem--,n--; } for(int i=1;i<=n;i++) { dp[i]=dp[max(i-k,0ll)]+min(m,a[i]*2); } s2=0; for(int i=n;i>=1;--i) dp2[i]=dp2[min(i+k,n+1)]+min((m-a[i])*2,m); s4=inf; for(int i=0;i<=n;i++) s4=min(s4,dp[i]+dp2[i+1]); return s4; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:60:13: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   60 |     for(int i=1; i<=N; i++)
      |             ^
boxes.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
boxes.cpp:65:10: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   65 |  for(int i=1;i<=n;i++)
      |          ^
boxes.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
boxes.cpp:70:11: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   70 |   for(int i=n;i>=1;--i)
      |           ^
boxes.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
boxes.cpp:70:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   70 |   for(int i=n;i>=1;--i)
      |             ^
boxes.cpp:73:12: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   73 |    for(int i=0;i<=n;i++)
      |            ^
boxes.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
boxes.cpp:73:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   73 |    for(int i=0;i<=n;i++)
      |    ^~~
boxes.cpp:75:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   75 |      return s4;
      |      ^~~~~~
#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...