제출 #654625

#제출 시각아이디문제언어결과실행 시간메모리
654625Markomafko972선물상자 (IOI15_boxes)C++14
20 / 100
1 ms340 KiB
#include "boxes.h" #include <bits/stdc++.h> #define X first #define Y second #define pb push_back #define pii pair<int, int> typedef long long ll; using namespace std; const int MOD = 1e9 + 7; const ll INF = 1e18; const int OFF = (1 << 20); vector<int> v; vector<int> v2; long long delivery(int n, int k, int l, int p[]) { for (int i = 0; i < n; i++) { if (p[i] == 0) continue; if (p[i] <= l/2) v.push_back(p[i]); else v2.push_back(p[i]); } long long sol = 0; for (int i = k-1; i < v.size(); i += k) sol += v[i]*2; for (int i = (int)v2.size()-k; i >= 0; i -= k) sol += (l-v2[i])*2; int kol = (int)v.size() % k; reverse(v.begin(), v.end()); while ((int)v.size() > kol) v.pop_back(); reverse(v.begin(), v.end()); kol = (int)v2.size() % k; reverse(v2.begin(), v2.end()); while((int)v2.size() > kol) v2.pop_back(); reverse(v2.begin(), v2.end()); long long dod = 2*l; for (int i = 0; i < v2.size(); i++) v.push_back(v2[i]); if (v.size() > 0) { long long tren = min(v.back()*2, (l-v[0])*2); for (int i = 0; i < (int)v.size()-1; i++) { tren = min(tren, (long long)v[i]*2+(l-v[i+1])*2); } dod = min(dod, tren); if (v.size() > k) { tren = min(v[(int)v.size()-k-1]*2, (l-v[k])*2); for (int i = 0; i+k+1 < (int)v.size(); i++) { tren = min(tren, (long long)v[i]*2+(l-v[i+k+1])*2); } tren += l; dod = min(dod, tren); } else dod = min(dod, (long long)l); } else dod = 0; sol += dod; return sol; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:25:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = k-1; i < v.size(); i += k) sol += v[i]*2;
      |                       ~~^~~~~~~~~~
boxes.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < v2.size(); i++) v.push_back(v2[i]);
      |                     ~~^~~~~~~~~~~
boxes.cpp:47:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |   if (v.size() > k) {
      |       ~~~~~~~~~^~~
#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...