제출 #305464

#제출 시각아이디문제언어결과실행 시간메모리
305464vipghn2003선물상자 (IOI15_boxes)C++14
0 / 100
1 ms384 KiB
#include<bits/stdc++.h> using namespace std; long long delivery(int n,int k,int L,int pos[]) { vector<long long>l(n+1),r(n+1); sort(pos,pos+n); int mid=L/2+1; int cntl=0; for(int i=0;i<n;i++) { cntl++; if(cntl>=k) l[cntl]=l[cntl-k]+2ll*pos[i]; else l[cntl]=2ll*pos[i]; } int cntr=0; for(int i=n-1;i>=0;i--) { cntr++; if(cntr>=k) r[cntr]=r[cntr-k]+2ll*(L-pos[i]+1); else r[cntr]=2ll*(L-pos[i]+1); } long long res=1e18; for(int i=0;i<=n;i++) { res=min(res,l[i]+r[n-i]); if(n-i-k>=0) res=min(res,l[i]+r[n-i-k]+L); } return res; } /* int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,k,L; cin>>n>>k>>L; int pos[n]; for(int i=0;i<n;i++) cin>>pos[i]; cout<<delivery(n,k,L,pos); }*/

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:8:9: warning: unused variable 'mid' [-Wunused-variable]
    8 |     int mid=L/2+1;
      |         ^~~
#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...