# include "boxes.h"
# pragma GCC optimize("Ofast,no-stack-protector")
# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;
int a[10000005];
int ans1[10000005],ans2[10000005];
int ans;
void f(int &s,int val)
{
//cout << val << '\n';
s = min(s,val);
}
#undef int
ll delivery(int n, int k, int L, int p[])
{
#define int ll
vector<int>vec;
for(int i = 0;i < n;i++) vec.pb(p[i]);
sort(vec.begin(),vec.end());
memset(ans1,0,sizeof(ans1));
memset(ans2,0,sizeof(ans2));
for(int i = 0;i < sz(vec);i++)
{
ans1[i] = (2ll * vec[i]) + (i >= k ? ans1[i - k] : 0);
}
for(int i = sz(vec) - 1;i >= 0;i--)
{
ans2[i] = (2ll * (L - vec[i])) + (i + k < sz(vec) ? ans2[i + k] : 0);
}
ans = 1e18;
f(ans,ans2[0]);
for(int i = 0;i < k - 1;i++) a[i] = 1e18;
for(int i = 0;i < sz(vec);i++)
{
f(ans,ans1[i] + ans2[i + 1]);
}
for(int i = k - 1;i < n;i++)
{
f(ans, ans2[i + 1] + a[i % k] + (i / k) * L);
a[i % k] = min(a[i % k],ans1[i] - (i / k) * L);
}
//cout << ans << '\n';
return ans;
}
Compilation message
boxes.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
# pragma GCC optimization ("unroll-loops")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
137 ms |
157008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
157 ms |
156960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
156920 KB |
Output is correct |
2 |
Incorrect |
157 ms |
156908 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
137 ms |
157008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
137 ms |
157008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
137 ms |
157008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |