제출 #1061275

#제출 시각아이디문제언어결과실행 시간메모리
1061275codefox선물상자 (IOI15_boxes)C++14
0 / 100
1 ms348 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]); } vector<ll> best1(first.size()); vector<ll> best2(second.size()); for (int i = 0; i < first.size(); i++) { if (i >= K) best1[i] = best1[i-K]+ first[i]*2; else best1[i] = first[i]*2; } for (int i = 0; i < second.size(); i++) { if (i>= K) best2[i] = best2[i-K]+ (L-second[i])*2; else best2[i] =(L-second[i])*2; } ll sol = 0; if (best1.size()) sol += best1.back(); if (best2.size()) sol += best2.back(); ll mn = 1e18; for (int i = 0; i <=K; i++) { if (best2.size()-K+i-1<-1) continue; if (best1.size()-i-1<-1) continue; ll aa = 0; ll bb = 0; if (best1.size()-i-1>=0) aa = best1[best1.size()-i-1]; if (best2.size()-K+i-1>=0) bb = best2[best2.size()-K+i-1]; mn = min(mn,aa+bb+L); } return min(mn, sol); }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < first.size(); i++)
      |                     ~~^~~~~~~~~~~~~~
boxes.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = 0; i < second.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
boxes.cpp:38:31: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         if (best2.size()-K+i-1<-1) continue;
      |             ~~~~~~~~~~~~~~~~~~^~~
boxes.cpp:39:29: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         if (best1.size()-i-1<-1)  continue;
      |             ~~~~~~~~~~~~~~~~^~~
boxes.cpp:42:29: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
   42 |         if (best1.size()-i-1>=0) aa =  best1[best1.size()-i-1];
      |             ~~~~~~~~~~~~~~~~^~~
boxes.cpp:43:31: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
   43 |         if (best2.size()-K+i-1>=0) bb =  best2[best2.size()-K+i-1];
      |             ~~~~~~~~~~~~~~~~~~^~~
#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...