제출 #1061550

#제출 시각아이디문제언어결과실행 시간메모리
1061550anango선물상자 (IOI15_boxes)C++17
0 / 100
0 ms348 KiB
#include "boxes.h" #include <bits/stdc++.h> #define int long long using namespace std; int getdist(int L, int l, int r) { //go from sections l to r, with L if (r<l) swap(l,r); return min(min(2*r,(L-l)*2),L); } long long delivery(signed N, signed K, signed L, signed p[]) { int k = K; int n = N; vector<int> vals(N); for (int i=0; i<N; i++) { vals[i] = p[i]; } sort(vals.begin(), vals.end()); int rem = N%K; long long co1 = 0; for (int i=0; i<=N-k; i+=k) { //i through i+k-1 co1+=getdist(L,vals[i],vals[i+k-1]); } co1+=getdist(L,vals[N-rem-1],vals[N-1]); reverse(vals.begin(), vals.end()); long long co2 = 0; for (int i=0; i<=N-k; i+=k) { //i through i+k-1 co2+=getdist(L,vals[i],vals[i+k-1]); } co2+=getdist(L,vals[N-rem-1],vals[N-1]); long long co = min(co1,co2); return co; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:13:20: warning: unused variable 'n' [-Wunused-variable]
   13 |     int k = K; int n = N;
      |                    ^
#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...