제출 #813124

#제출 시각아이디문제언어결과실행 시간메모리
813124Kerim선물상자 (IOI15_boxes)C++17
50 / 100
2059 ms26108 KiB
#include "boxes.h" #include "bits/stdc++.h" using namespace std; #define ll long long int f(int n, int k){ return (n+k-1) / k; } long long delivery(int n, int k, int l, int p[]) { ll answer = f(n, k) * 1LL * l; vector<int> arr(n+2); arr[n+1] = l; for (int i = 1; i <= n; i++) arr[i] = p[i-1]; vector<ll> pref(n+2), suf(n+2); for (int i = 1; i <= n; i++){ pref[i] = arr[i]; if (i >= k) pref[i] += pref[i-k]; } for (int i = n; i >= 1; i--){ suf[i] = l - arr[i]; if (i + k <= n) suf[i] += suf[i+k]; } if(k == n){//subtask2 answer = l; for (int i = 0; i + 1 <= n + 1; i++) answer = min(answer, 2LL * (arr[i] + l - arr[i+1])); } else if(n <= 1000){ for (int i = 0; i <= n; i++) for (int j = i+1; j <= n+1; j++){ int c = f(j-i-1, k); answer = min(answer, c*1LL*l + 2*(pref[i] + suf[j])); } } else{//small k for (int i = 0; i <= n; i++){ for (int c = 0; c*1LL*k+1+i <= n+1; c++){ int j = c*1LL*k+1+i; answer = min(answer, c*1LL*l + 2*(pref[i] + suf[j])); } } } return answer; }

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:42:34: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   42 |                 int j = c*1LL*k+1+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...