제출 #307683

#제출 시각아이디문제언어결과실행 시간메모리
307683kylych03선물상자 (IOI15_boxes)C++14
20 / 100
1 ms384 KiB
#include <bits/stdc++.h> #include "boxes.h" //#include "grader.cpp" using namespace std; long long delivery(int N, int K, int L, int p[]) { sort(p, p+N); vector <long long > a,b; for(int i = 0; i < N; i++){ if(p[i] <= L/2) a.push_back(p[i]); else b.push_back(L-p[i]); } sort(b.begin(), b.end()); long long res = 0; for(int i = 0 ; i < a.size();i++){ if((i+1)% K == 0) res += (a[i] * 2); } for(int i = 0 ; i < b.size();i++) if((i+1)%K == 0) res+=(b[i] * 2); if(a.size()%K !=0) res+=(a[a.size() - 1] * 2); if(b.size()%K!=0) res+=( b[b.size() - 1] * 2); long long res1 = L; while(K--) { if(a.size()==0 && b.size()==0) break; if(a.size()==0){ b.pop_back(); continue; } if(b.size()==0){ a.pop_back(); continue; } if(a.back() > b.back()) a.pop_back(); else b.pop_back(); } for(int i = 0 ; i < a.size();i++){ if((i+1)% K == 0) res1 += (a[i] * 2); } for(int i = 0 ; i < b.size();i++) if((i+1)%K == 0) res1+=(b[i] * 2); if(a.size()%K !=0) res1+=(a[a.size() - 1] * 2); if(b.size()%K!=0) res1+=( b[b.size() - 1] * 2); if(res1 < res) res= res1; return res; }

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

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