# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
572077 | nohaxjustsoflo | 선물상자 (IOI15_boxes) | C++17 | 654 ms | 333040 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen(-1e9, 1e8); ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN = 1e6+50000;
const int mod = 1e9+7;
const int mxlogN = 34;
const int mxK = 26;
const ll inf = 1e18;
const int K = 100000;
ll delivery(int N, int K, int L, int p[])
{
ll n=N, k=K;
ll cnt=0;
if(n%2==0) for(int i=0; i<n; i++) cnt+=p[i]==n/2;
ll ans=cnt/k*n;
cnt=cnt%k;
vector<int> a;
for(int i=0; i<n; i++)
{
if(n%2==0&&p[i]==n/2)
{
if(cnt)
{
cnt--;
a.push_back(p[i]);
}
}
else a.push_back(p[i]);
}
n=a.size();
vector<ll> pre(n), suf(n);
for(int i=0; i<n; i++)
{
if(i>=k) pre[i]+=pre[i-k];
pre[i]+=a[i]*2;
//cout << pre[i] << " ";
}
//cout << "\n";
for(int i=n-1; i>=0; i--)
{
if(i+k<n) suf[i]+=suf[i+k];
suf[i]+=(L-a[i])*2;
//cout << suf[i] << " ";
}
//cout << "\n";
ll ans2=1e18;
for(int j=0; j<3; j++)
{
for(int i=0; i+j*K<=n; i++)
{
//pre[i-1]+suf[i];
ans2=min(ans2,L*j+(i?pre[i-1]:0)+(i+j*K<n?suf[i+j*K]:0));
}
}
return ans+ans2;
}
/*
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,k,l; cin >> n >> k >> l;
int p[n];
for(int i=0; i<n; i++) cin >> p[i];
cout << delivery(n,k,l,p) << "\n";
}*/
/*
3 2 8
1 2 5
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |