제출 #976767

#제출 시각아이디문제언어결과실행 시간메모리
976767Amaarsaa선물상자 (IOI15_boxes)C++14
35 / 100
1 ms596 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long ; ll delivery(int N, int K, int L, int p[]) { ll ans, cnt_ard, cnt_urd, res; vector < ll > ard, urd; ll cnt = 0, i, j, r, s; for (i = 0; i < N; i ++) { if (p[i] == 0) continue; if ( p[i] * 2 > L) { ard.push_back(p[i]); } else { if (p[i] * 2 < L) urd.push_back(p[i]); else cnt ++; } } ans = 0; reverse(ard.begin(), ard.end()); for (i = urd.size() - 1; i >= K -1; i -= K) ans += (urd[i]); j = i ; for (i = ard.size() - 1; i >= K - 1; i -= K) ans += ( L - ard[i]); r = i ; ans *= 2; // cout << ans << endl; cnt_urd = j + 1; cnt_ard = r + 1; // cout << cnt_urd << " " << cnt_ard << endl; res = ((cnt_ard + cnt_urd + cnt + K - 1) / K) * L; if ( cnt_ard != 0) { res = min(res, (((L - ard[r]) * 2) + ((cnt_urd + cnt + K - 1)/K) * L) ); } if ( cnt_urd != 0) { res = min(res, (((urd[j]) * 2) + ((cnt_ard + cnt + K - 1)/K) * L) ); } if ( cnt_ard != 0 && cnt_urd != 0) { res = min(res, (((L - ard[r]) * 2) + (urd[j] * 2)+ ((cnt + K - 1)/K) * L) ); } return res + ans; }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:9:23: warning: unused variable 's' [-Wunused-variable]
    9 |  ll cnt = 0, i, j, r, s;
      |                       ^
#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...