Submission #782589

#TimeUsernameProblemLanguageResultExecution timeMemory
782589ymmBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms340 KiB
#include "boxes.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) typedef long long ll; using namespace std; vector<ll> al, dpl, ar, dpr; long long delivery(int N, int K, int L, int p[]) { Loop (i,0,N) { if (p[i] > L-p[i]) ar.push_back(L-p[i]); else al.push_back(p[i]); } sort(al.begin(), al.end()); sort(ar.begin(), ar.end()); Loop (dard,0,2) { auto &a = dard? ar: al; auto &dp = dard? dpr: dpl; dp.resize(a.size()); Loop (i,0,a.size()) dp[i] = i < K? 2*a[i]: 2*a[i] + dp[i-K]; } ll ans = dpl.back() + dpr.back(); Loop (i,0,K) { int x = (int)dpl.size()-1-i; int y = (int)dpr.size()-1-K+i; if (x < 0 || y < 0) continue; ans = min(ans, dpl[x] + dpr[y] + L); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:3:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
      |                                        ^
boxes.cpp:22:3: note: in expansion of macro 'Loop'
   22 |   Loop (i,0,a.size())
      |   ^~~~
boxes.cpp:27:28: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   27 |   int x = (int)dpl.size()-1-i;
      |           ~~~~~~~~~~~~~~~~~^~
boxes.cpp:28:30: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   28 |   int y = (int)dpr.size()-1-K+i;
      |           ~~~~~~~~~~~~~~~~~~~^~
#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...