Submission #571990

#TimeUsernameProblemLanguageResultExecution timeMemory
571990kwongwengBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms340 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef pair<ll, ll> pll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define ms memset #define pb push_back #define fi first #define se second ll delivery(int N, int K, int L, int p[]) { vi l, r; vector<ll> suml(K), sumr(K); FOR(i,0,N){ if (p[i] > L/2) break; l.pb(p[i]); suml[(i+1)%K] += p[i]*2; } int m = l.size(); ROF(i,N-1,m){ r.pb(L-p[i]); sumr[(i+1)%K] += (L-p[i])*2; } ll ans = 1000000000000000000; ans = suml[m%K] + sumr[(N-m)%K]; FOR(i,1,min(m+1,K)){ if (N-m < K-i) continue; ans = min(ans, suml[(m-i)%K] + sumr[(N-m-(K-i))%K] + L); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:27:19: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   27 |     int m = l.size();
      |             ~~~~~~^~
#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...