제출 #787043

#제출 시각아이디문제언어결과실행 시간메모리
787043GusterGoose27선물상자 (IOI15_boxes)C++17
0 / 100
2057 ms284 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 15; const ll inf = 1e18; bool vis[MAXN]; ll cost(int n, int k, int l, int p[], vector<int> &v) { int mn, mx; int res = 0; ll ans = 0; for (int i = 0; i < n; i++) { if (res == 0) { mn = p[v[i]]; mx = p[v[i]]; } else { mn = min(mn, p[v[i]]); mx = max(mx, p[v[i]]); } if (res == k-1 || i == n-1) { ans += min(min(2*(l-mn), 2*mx), l); } res = (res+1)%k; } return ans; } ll make(int n, int k, int l, int p[], vector<int> &v) { if (v.size() == n) return cost(n, k, l, p, v); ll best = inf; for (int i = 0; i < n; i++) { if (vis[i]) continue; v.push_back(i); vis[i] = 1; best = min(make(n, k, l, p, v), best); vis[i] = 0; v.pop_back(); } return best; } ll delivery(int n, int k, int l, int p[]) { vector<int> v; return make(n, k, l, p, v); }

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

boxes.cpp: In function 'll make(int, int, int, int*, std::vector<int>&)':
boxes.cpp:35:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |  if (v.size() == n) return cost(n, k, l, p, v);
      |      ~~~~~~~~~^~~~
#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...