제출 #519626

#제출 시각아이디문제언어결과실행 시간메모리
519626silverfish선물상자 (IOI15_boxes)C++17
0 / 100
290 ms476524 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long; const ll N = 10000007, inf = 1e18+10; ll dp[N], s[N]; array<ll,2> fen[N]; void ins(ll v, int p){ int po = p; for(;p<N;p+=p&-p){ if(v < fen[p][0]){ fen[p][0] = v; fen[p][1] = po; } } } int get(int p){ ll mn=inf, mnpos = -1; for(;p;p-=p&-p){ if(fen[p][0] < mn){ mn = fen[p][0]; mnpos = fen[p][1]; } } return mnpos; } long long delivery(int n, int k, int L, int p[]) { ll l = L; fill(dp, dp+N, inf); fill(fen, fen+N, array<ll,2>{inf, -1}); for(int i = 0; i < n; ++i){ s[i] = (i ? dp[i-1] : 0) + min(2LL*(l-p[i]), l); ins(s[i], n-i); int pos = n-get(n-i+k-1); assert(pos - 1 >= 0); dp[i] = dp[pos-1]+min({l,2LL*p[i], 2LL*(l-p[pos])}); } return dp[n-1]; }

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

boxes.cpp: In function 'int get(int)':
boxes.cpp:28:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   28 |         return mnpos;
      |                ^~~~~
#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...