제출 #1061161

#제출 시각아이디문제언어결과실행 시간메모리
1061161codefox선물상자 (IOI15_boxes)C++14
20 / 100
1 ms600 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; #define ll long long ll delivery(int N,int K,int L,int positions[]) { deque<ll> first; deque<ll> second; for (int i = 0;i < N; i++) { if (positions[i]==0) continue; if (positions[i]<=L/2) first.push_back(positions[i]); else second.push_front(positions[i]); } ll sol = 0; while (first.size() >= K) { int t = K; sol += first[K-1]*2; while (t--) first.pop_front(); } while (second.size() >= K) { int t = K; sol += (L-second[K-1])*2; while (t--) second.pop_front(); } if (first.size()==0 && second.size()==0) return sol; if (first.size() == 0) return sol+(L-second.back())*2; if (second.size()==0) return sol+first.back()*2; ll mn = 1e18; if (first.size()+second.size()<=K) mn = L; else { mn = min(mn, L+2*first[first.size()+second.size()-K]); mn = min(mn, L+2*second[first.size()+second.size()-K]); } mn = min(mn, 2*(first.back()+L-second.back())); return sol+mn; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:25: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     while (first.size() >= K)
      |            ~~~~~~~~~~~~~^~~~
boxes.cpp:25:26: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while (second.size() >= K)
      |            ~~~~~~~~~~~~~~^~~~
boxes.cpp:35:35: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |     if (first.size()+second.size()<=K) mn = L;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
#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...