Submission #923659

# Submission time Handle Problem Language Result Execution time Memory
923659 2024-02-07T14:32:49 Z Aiperiii Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
1 ms 348 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>=1)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>=1)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-a.size()+i+1;
         int pos=b.size()-i-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:19:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |    for(int i=1;i<a.size();i++){
      |                ~^~~~~~~~~
boxes.cpp:23:17: 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=1;i<b.size();i++){
      |                ~^~~~~~~~~
boxes.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    for(int i=0;i<a.size();i++){
      |                ~^~~~~~~~~
boxes.cpp:29:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |       if(a.size()-i-1>K){
      |          ~~~~~~~~~~~~^~
boxes.cpp:30:28: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   30 |          int x=K-a.size()+i+1;
      |                ~~~~~~~~~~~~^~
boxes.cpp:31:30: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   31 |          int pos=b.size()-i-1-x;
      |                  ~~~~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -