Submission #754462

#TimeUsernameProblemLanguageResultExecution timeMemory
754462sofija6Boxes with souvenirs (IOI15_boxes)C++14
25 / 100
1 ms300 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<int> left,right; for (int i=0;i<N && p[i]<=L/2;i++) left.push_back(p[i]); for (int i=N-1;i>=0 && p[i]>L/2;i--) right.push_back(p[i]); long long ans=LLONG_MAX,cur=0; for (int i=left.size()-1;i>=0;i-=K) cur+=2*left[i]; for (int i=right.size()-1;i>=0;i-=K) cur+=2*(L-right[i]); ans=min(ans,cur); cur=L; for (int i=left.size()-left.size()%K-1;i>=0;i-=K) cur+=2*left[i]; for (int i=right.size()-(K-left.size()%K)-1;i>=0;i-=K) cur+=2*(L-right[i]); ans=min(ans,cur); cur=L; for (int i=left.size()-(K-right.size()%K)-1;i>=0;i-=K) cur+=2*left[i]; for (int i=right.size()-right.size()-1;i>=0;i-=K) cur+=2*(L-right[i]); return min(ans,cur); }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:12:27: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   12 |     for (int i=left.size()-1;i>=0;i-=K)
      |                ~~~~~~~~~~~^~
boxes.cpp:14:28: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   14 |     for (int i=right.size()-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~^~
boxes.cpp:18:41: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   18 |     for (int i=left.size()-left.size()%K-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~^~
boxes.cpp:20:46: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   20 |     for (int i=right.size()-(K-left.size()%K)-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
boxes.cpp:24:46: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   24 |     for (int i=left.size()-(K-right.size()%K)-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
boxes.cpp:26:41: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   26 |     for (int i=right.size()-right.size()-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~^~
#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...