제출 #268573

#제출 시각아이디문제언어결과실행 시간메모리
268573A02선물상자 (IOI15_boxes)C++14
20 / 100
1 ms384 KiB
#include "boxes.h" #include <vector> #include <set> #include <algorithm> #include <utility> #include <iostream> using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<long long> left_positions; vector<long long> right_positions; long long no_round_trips = 0; for (int i = 0; i < N; i++){ if (p[i] <= L/2){ left_positions.push_back(p[i]); } } for (int i = N - 1; i >= 0; i--){ if (p[i] > L/2){ right_positions.push_back(L - p[i]); } } int current_boxes = 0; while (left_positions.size() > 0){ no_round_trips += left_positions[left_positions.size() - 1] * 2; current_boxes = K; for (;left_positions.size() && current_boxes > 0; current_boxes--){ left_positions.pop_back(); } } while (right_positions.size() > 0){ no_round_trips += right_positions[right_positions.size() - 1] * 2; current_boxes = K; for (; right_positions.size() && current_boxes > 0; current_boxes--){ right_positions.pop_back(); } } long long one_round_trip = L; for (int i = 0; i < N; i++){ if (p[i] <= L/2){ left_positions.push_back(p[i]); } } for (int i = N - 1; i >= 0; i--){ if (p[i] > L/2){ right_positions.push_back(L - p[i]); } } int current_l_index = 0; current_boxes = 0; while (current_l_index != left_positions.size()){ current_boxes = K; while (current_boxes > 0 && current_l_index != left_positions.size()){ current_boxes--; current_l_index++; } if (current_l_index != left_positions.size()){ one_round_trip += left_positions[current_l_index] * 2; } } for (; right_positions.size() && current_boxes > 0; current_boxes--){ right_positions.pop_back(); } while (right_positions.size() > 0){ one_round_trip += right_positions[right_positions.size() - 1] * 2; current_boxes = K; for (; right_positions.size() && current_boxes > 0; current_boxes--){ right_positions.pop_back(); } } return min(one_round_trip, no_round_trips); return 0; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:70:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     while (current_l_index != left_positions.size()){
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:74:53: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |         while (current_boxes > 0 && current_l_index != left_positions.size()){
      |                                     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:79:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         if (current_l_index != left_positions.size()){
      |             ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...