제출 #396957

#제출 시각아이디문제언어결과실행 시간메모리
396957Andyvanh1선물상자 (IOI15_boxes)C++14
20 / 100
1 ms288 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <math.h> using namespace std; #define pb push_back #define INF INT32_MAX #define vt vector typedef vt<int> vi; typedef pair<int,int> pii; typedef tuple<int,int,int> tiii; typedef long long ll; #define MOD 1000000007 ll delivery(int n, int k, int l, int arr[]){ if(k==1){ ll ans = 0; for(int i = 0; i < n; i++){ ans+=2*min(arr[i],l-arr[i]); } return ans; }else if(k==n){ if(arr[n-1]<=l/2){ return arr[n-1]*2; }else if(arr[0]>l/2){ return 2* (l-arr[0]); }else{ int Max1 = 0; int Max2 = 0; int i = 0; for(; i < n; i++){ if(arr[i]<=l/2){ Max1 = max(Max1, arr[i]); }else{ break; } } Max2 = arr[i]; return min(l,2*(Max1+l-Max2)); } }else{ vi vals1(n+1); vi vals2(n+1); vt<ll> dp(n+1); dp[0] = 0; multiset<ll> pq1; pq1.insert(0); vals1[0]=0; multiset<ll> pq2; pq2.insert(0); vals2[0] = 0; for(int i = 1; i <= n; i++){ dp[i] = *(pq1.begin())+2*l; dp[i] = min(dp[i],min(*(pq2.begin())+2*arr[i-1],*(pq2.begin())+l)); vals1[i] = dp[i]-2*arr[i-1]; vals2[i] = dp[i]; pq1.insert(vals1[i]); pq2.insert(vals2[i]); if(i-k>=0){ pq1.erase(pq1.find(vals1[i-k])); pq2.erase(pq2.find(vals2[i-k])); } } return dp[n]; } }

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

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:69:29: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} may change value [-Wconversion]
   69 |             vals1[i] = dp[i]-2*arr[i-1];
boxes.cpp:70:28: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} may change value [-Wconversion]
   70 |             vals2[i] = dp[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...