제출 #1186498

#제출 시각아이디문제언어결과실행 시간메모리
1186498Malix선물상자 (IOI15_boxes)C++20
0 / 100
0 ms328 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int,int> pi; typedef vector<pi> pii; typedef tuple<int,int,int> ti; typedef vector<ll> li; typedef vector<li> lii; #define REP(i,a,b) for(int i=a;i<b;i++) #define F first #define S second #define PB push_back #define LSOne(s) ((s)&(-s)) ll INF=1000000000000000010; int inf=1e9+10; ll M=1e9+7; long long delivery(int n, int m, int L, int p[]) { vi a; ll c=0; int pos=0; while(pos<=n){ int x=p[pos]; a.PB(x); if(pos-m>=0&&p[pos]>L/2&&p[pos-m]<L/2){ c+=L; pos+=m; continue; } x=min(x,L-x+m-1); c+=x*2LL; if(pos==n)break; pos+=m; if(pos>n)pos=n; } ll ans=c; int sz=a.size(); REP(j,2,m+1){ c=0; REP(i,0,sz){ a[i]++; if(a[i]>n)a[i]=n; int x=a[i]; if(i>0&&a[i]>L/2&&a[i-1]<L/2){ c+=L; continue; } x=min(x,L-x+m-1); c+=x*2LL; } ans=min(ans,c); } return ans; }
#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...