제출 #1042134

#제출 시각아이디문제언어결과실행 시간메모리
1042134biserailieva선물상자 (IOI15_boxes)C++14
20 / 100
1 ms348 KiB
#include "boxes.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; ll delivery(int n, int k, int l, int pos[]){ ll mid = (l+1)/2; vector<ll> dp1, dp2; dp1.push_back(0); dp2.push_back(0); for(int i = 0; i < n && pos[i]<=mid; i++){ if(i==0){ dp1.push_back(pos[i]*2); continue; } if(i%k!=0)dp1.push_back(dp1.back()+2*abs(pos[i]-pos[i-1])); else dp1.push_back(dp1.back()+(2*pos[i])); } for(int x = n-1; x >= 0 && pos[x]>=mid; x--){ if(x==n-1){ dp2.push_back((l-pos[x])*2); continue; } ll ind = x-n+1; if(ind%k!=0)dp2.push_back(dp2.back()+2*abs(pos[x]-pos[x+1])); else dp2.push_back(dp2.back()+2*(l-pos[x])); } ll rez = 1e18; for(int i = 0; i < dp1.size(); i++){ if(dp2.size()>n-i)rez=min(rez, dp1[i] + dp2[n-i]); if(dp2.size()>n-i-k&&n-i-k>=0)rez=min(rez, dp1[i] + dp2[n-i-k] + l); } return rez; }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i < dp1.size(); i++){
      |                    ~~^~~~~~~~~~~~
boxes.cpp:39:22: 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(dp2.size()>n-i)rez=min(rez, dp1[i] + dp2[n-i]);
      |            ~~~~~~~~~~^~~~
boxes.cpp:40:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |         if(dp2.size()>n-i-k&&n-i-k>=0)rez=min(rez, dp1[i] + dp2[n-i-k] + 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...