제출 #923663

#제출 시각아이디문제언어결과실행 시간메모리
923663Aiperiii선물상자 (IOI15_boxes)C++14
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "boxes.h" #define ll long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; long long delivery(int N, int K, int L, int p[]) { vector <ll> a,b,dpa,dpb; for(int i=0;i<N;i++){ if(p[i]<=L-p[i])a.pb(p[i]); else b.pb(L-p[i]); } a.pb(0);b.pb(0); dpa.pb(0);dpb.pb(0); sort(all(a));sort(all(b)); for(int i=1;i<a.size();i++){ if(i>=K)dpa.pb(dpa[i-K]+2*a[i]); else dpa.pb(2*a[i]); } for(int i=1;i<b.size();i++){ if(i>=K)dpb.pb(dpb[i-K]+2*b[i]); else dpb.pb(2*b[i]); } ll ans=dpa.back()+dpb.back(); for(int i=0;i<a.size();i++){ if(a.size()-i-1>K){ int x=K-(int)a.size()+i+1; int pos=(int)b.size()-1-x; if(pos<0)pos=0; ans=min(ans,a[i]+b[pos]+L); } } return ans; } /* signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n,k,l; cin>>n>>k>>l; int pos[n]; for(int i=0;i<n;i++)cin>>pos[i]; cout<<delivery(n,k,l,pos); } */

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |    for(int i=1;i<a.size();i++){
      |                ~^~~~~~~~~
boxes.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |    for(int i=1;i<b.size();i++){
      |                ~^~~~~~~~~
boxes.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    for(int i=0;i<a.size();i++){
      |                ~^~~~~~~~~
boxes.cpp:30:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |       if(a.size()-i-1>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...