Submission #668846

#TimeUsernameProblemLanguageResultExecution timeMemory
668846AstraytBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define pii pair<int,int> #define All(x) x.begin(), x.end() ll delivery(int N, int K, int L, int pos[]){ ll ans = 0; vector<int> lp, rp; int in_mid = 0; for(int i = 0; i < N; ++i){ if(pos[i] != 0 && pos[i] <= L / 2) lp.pb(pos[i]); else if(pos[i] > L / 2) rp.pb(pos[i]); } reverse(All(rp)); int cur = lp.size() + rp.size(); for(int i = cur; i > 0; i -= K){ int k = min(K, i); ll ml = 0, mr = 0; for(; k; k--){ int l, r; l = (lp.size() ? lp.back() : -1), r = (rp.size() ? rp.back() : L + 1); if(mr && r != L + 1) rp.pop_back(), mr = max(mr, 1ll * (L - r)); else if(ml && l != -1) lp.pop_back(), ml = max(ml, 1ll * l); else { if(mr == 0 && ml && l == -1 && 2ll * ml + 2ll * (L - r) < L) break; if(ml == 0 && mr && r == L + 1 && 2ll * mr + 2ll * l < L) break; if(r == L + 1) lp.pop_back(), ml = max(ml, 1ll * l); else rp.pop_back(), mr = max(mr, 1ll * (L - r)); } } ans += min(2ll * (ml + mr), 1ll * L); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:22: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   17 |  int cur = lp.size() + rp.size();
      |            ~~~~~~~~~~^~~~~~~~~~~
boxes.cpp:11:6: warning: unused variable 'in_mid' [-Wunused-variable]
   11 |  int in_mid = 0;
      |      ^~~~~~
#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...