Submission #1032563

#TimeUsernameProblemLanguageResultExecution timeMemory
1032563socpiteBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
38 ms78712 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; const int maxn = 1e7+5; const long long INF = 1e18; long long cnt[maxn], ans[maxn], dp[maxn]; long long delivery(int N, int K, int L, int p[]) { for(int i = 0; i < N; i++)cnt[p[i]]++; N -= cnt[0]; int crr = 0; for(int i = 1; i < L; i++){ for(int _ = 0; _ < cnt[i]; _++){ dp[crr++%K] += i + min(i, L - i); ans[crr] = dp[(crr-1)%K]; } } memset(dp, 0, sizeof(dp)); crr = 0; long long re = INF; for(int i = 1; i < L; i++){ for(int _ = 0; _ < cnt[L-i]; _++){ dp[crr++%K] += i + min(i, L - i); re = min(re, dp[(crr-1)%K] + ans[N - crr]); } } return re; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:12:7: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   12 |     N -= cnt[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...