Submission #519613

#TimeUsernameProblemLanguageResultExecution timeMemory
519613silverfishBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long; const int N = 10000007; ll dp[N], s[N]; set<array<ll,2>> st; long long delivery(int n, int k, int L, int p[]) { ll l = L; fill(dp, dp+N, 1e18+10); sort(p, p+n); for(int i = 0; i < n; ++i){ s[i] = (i ? dp[i-1] : 0) + min(2LL*(l-p[i]), l); st.insert({s[i], i}); if(i-k >= 0) st.erase(st.find({s[i-k], i-k})); auto it = st.begin(); int pos = (*it)[1]; dp[i] = dp[pos-1] + min({l, 2LL*p[i], 2LL*(l-p[pos])); } return dp[n-1]; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:21:20: warning: conversion from 'std::array<long long int, 2>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   21 |   int pos = (*it)[1];
      |                    ^
boxes.cpp:23:55: error: expected '}' before ')' token
   23 |   dp[i] = dp[pos-1] + min({l, 2LL*p[i], 2LL*(l-p[pos]));
      |                           ~                           ^