Submission #923663

# Submission time Handle Problem Language Result Execution time Memory
923663 2024-02-07T14:35:56 Z Aiperiii Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
1 ms 600 KB
 #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);
}

*/

Compilation message

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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -