Submission #1007931

#TimeUsernameProblemLanguageResultExecution timeMemory
1007931androBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; long long delivery(int N, int K, int L, int p[]) { long long ans = 0; vector<int> b1, b2; for(int i = 0; i < N; i++) { if(p[i] <= L - p[i]) { b1.push_back(p[i]); } else { b2.push_back(p[i]); } } int r = K; for(int i = 0; i < b1.size(); i++) { r -= 1; if(! r) { ans += b1[i] * 2; r = K; } else { continue; } } int idx = b2.size() - 1; if(r != K) { while(r > 0) { idx -= 1; r -= 1; } ans += (L - b2[idx]) * 2; } r = K; for(int i = 0; i <= idx; i++) { r -= 1; if(! r) { ans += (L - b2[i]) * 2; r = K; } else { continue; } } if(r != K) { if(r > 0) { ans += (L - b2[idx]) * 2; } } return ans; } /* int main() { int X[3] = {1, 2, 5}; cout << delivery(3, 2, 8, X); }*/

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 0; i < b1.size(); i++) {
      |                    ~~^~~~~~~~~~~
boxes.cpp:29:25: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   29 |     int idx = b2.size() - 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...