Submission #307687

#TimeUsernameProblemLanguageResultExecution timeMemory
307687kylych03Boxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #include "boxes.h" //#include "grader.cpp" using namespace std; long long pra[100001], prb[100001]; 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<K) pra[i] = a[i]*2; else pra[i] = a[i] * 2 + pra[i-K]; for(int i = 0 ; i < b.size();i++) if(i<K) prb[i] = b[i]*2; else prb[i] = b[i] * 2 + prb[i-K]; if(a.size()==0) res = prb[b.size() -1 ]; else if(b.size()==0) res = prb[a.size() -1 ]; else res = pra[a.size() - 1] + prb[b.size() -1 ]; int x = 0; for(int i = a.size() - 2, j= 1; j <= K && i>=0 ; j++,i--){ if(b.size() >= K - j) x = prb[b.size() - (K-j)-1]; else x = 0; res = min (res, pra[i] + L + x); } return res; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:24: 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 = 0 ; i < a.size();i++)
      |                      ~~^~~~~~~~~~
boxes.cpp:25:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int  i = 0 ; i < b.size();i++)
      |                      ~~^~~~~~~~~~
boxes.cpp:39:27: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   39 |     for(int i  = a.size() - 2, j= 1; j <= K && i>=0 ; j++,i--){
      |                  ~~~~~~~~~^~~
boxes.cpp:40:21: 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(b.size() >= K - j)
      |            ~~~~~~~~~^~~~~~~~
boxes.cpp:41:39: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   41 |             x = prb[b.size() - (K-j)-1];
      |                 ~~~~~~~~~~~~~~~~~~~~~~^
#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...