# 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 ans1[1 << 20],ans2[1 << 20];
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 < sz(vec);i++)
{
f(ans,ans1[i] + ans2[i + 1]);
}
for(int i = 0;i < sz(vec);i++)
{
for(int j = i + k - 1;j < sz(vec);j += k)
{
f(ans,(i ? ans1[i - 1] : 0) + ((j - i + 1) / k) * L + ans2[j + 1]);
}
}
//cout << ans << '\n';
return ans;
}
Compilation message
boxes.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
# pragma GCC optimization ("unroll-loops")
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
16764 KB |
Output is correct |
2 |
Correct |
22 ms |
16760 KB |
Output is correct |
3 |
Correct |
22 ms |
16760 KB |
Output is correct |
4 |
Correct |
22 ms |
16760 KB |
Output is correct |
5 |
Correct |
22 ms |
16760 KB |
Output is correct |
6 |
Correct |
22 ms |
16760 KB |
Output is correct |
7 |
Correct |
23 ms |
16760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
16760 KB |
Output is correct |
2 |
Correct |
16 ms |
16760 KB |
Output is correct |
3 |
Correct |
16 ms |
16760 KB |
Output is correct |
4 |
Correct |
16 ms |
16760 KB |
Output is correct |
5 |
Correct |
16 ms |
16760 KB |
Output is correct |
6 |
Correct |
19 ms |
16760 KB |
Output is correct |
7 |
Correct |
16 ms |
16760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
16688 KB |
Output is correct |
2 |
Correct |
19 ms |
16760 KB |
Output is correct |
3 |
Correct |
16 ms |
16760 KB |
Output is correct |
4 |
Correct |
16 ms |
16760 KB |
Output is correct |
5 |
Correct |
16 ms |
16760 KB |
Output is correct |
6 |
Correct |
16 ms |
16760 KB |
Output is correct |
7 |
Correct |
16 ms |
16760 KB |
Output is correct |
8 |
Correct |
16 ms |
16760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
16764 KB |
Output is correct |
2 |
Correct |
22 ms |
16760 KB |
Output is correct |
3 |
Correct |
22 ms |
16760 KB |
Output is correct |
4 |
Correct |
22 ms |
16760 KB |
Output is correct |
5 |
Correct |
22 ms |
16760 KB |
Output is correct |
6 |
Correct |
22 ms |
16760 KB |
Output is correct |
7 |
Correct |
23 ms |
16760 KB |
Output is correct |
8 |
Correct |
16 ms |
16760 KB |
Output is correct |
9 |
Correct |
16 ms |
16760 KB |
Output is correct |
10 |
Correct |
16 ms |
16760 KB |
Output is correct |
11 |
Correct |
16 ms |
16760 KB |
Output is correct |
12 |
Correct |
16 ms |
16760 KB |
Output is correct |
13 |
Correct |
19 ms |
16760 KB |
Output is correct |
14 |
Correct |
16 ms |
16760 KB |
Output is correct |
15 |
Correct |
16 ms |
16688 KB |
Output is correct |
16 |
Correct |
19 ms |
16760 KB |
Output is correct |
17 |
Correct |
16 ms |
16760 KB |
Output is correct |
18 |
Correct |
16 ms |
16760 KB |
Output is correct |
19 |
Correct |
16 ms |
16760 KB |
Output is correct |
20 |
Correct |
16 ms |
16760 KB |
Output is correct |
21 |
Correct |
16 ms |
16760 KB |
Output is correct |
22 |
Correct |
16 ms |
16760 KB |
Output is correct |
23 |
Correct |
16 ms |
16760 KB |
Output is correct |
24 |
Correct |
16 ms |
16760 KB |
Output is correct |
25 |
Correct |
17 ms |
16760 KB |
Output is correct |
26 |
Correct |
16 ms |
16760 KB |
Output is correct |
27 |
Correct |
15 ms |
16764 KB |
Output is correct |
28 |
Correct |
16 ms |
16760 KB |
Output is correct |
29 |
Correct |
16 ms |
16760 KB |
Output is correct |
30 |
Correct |
16 ms |
16760 KB |
Output is correct |
31 |
Correct |
19 ms |
16760 KB |
Output is correct |
32 |
Correct |
16 ms |
16760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
16764 KB |
Output is correct |
2 |
Correct |
22 ms |
16760 KB |
Output is correct |
3 |
Correct |
22 ms |
16760 KB |
Output is correct |
4 |
Correct |
22 ms |
16760 KB |
Output is correct |
5 |
Correct |
22 ms |
16760 KB |
Output is correct |
6 |
Correct |
22 ms |
16760 KB |
Output is correct |
7 |
Correct |
23 ms |
16760 KB |
Output is correct |
8 |
Correct |
16 ms |
16760 KB |
Output is correct |
9 |
Correct |
16 ms |
16760 KB |
Output is correct |
10 |
Correct |
16 ms |
16760 KB |
Output is correct |
11 |
Correct |
16 ms |
16760 KB |
Output is correct |
12 |
Correct |
16 ms |
16760 KB |
Output is correct |
13 |
Correct |
19 ms |
16760 KB |
Output is correct |
14 |
Correct |
16 ms |
16760 KB |
Output is correct |
15 |
Correct |
16 ms |
16688 KB |
Output is correct |
16 |
Correct |
19 ms |
16760 KB |
Output is correct |
17 |
Correct |
16 ms |
16760 KB |
Output is correct |
18 |
Correct |
16 ms |
16760 KB |
Output is correct |
19 |
Correct |
16 ms |
16760 KB |
Output is correct |
20 |
Correct |
16 ms |
16760 KB |
Output is correct |
21 |
Correct |
16 ms |
16760 KB |
Output is correct |
22 |
Correct |
16 ms |
16760 KB |
Output is correct |
23 |
Correct |
16 ms |
16760 KB |
Output is correct |
24 |
Correct |
16 ms |
16760 KB |
Output is correct |
25 |
Correct |
17 ms |
16760 KB |
Output is correct |
26 |
Correct |
16 ms |
16760 KB |
Output is correct |
27 |
Correct |
15 ms |
16764 KB |
Output is correct |
28 |
Correct |
16 ms |
16760 KB |
Output is correct |
29 |
Correct |
16 ms |
16760 KB |
Output is correct |
30 |
Correct |
16 ms |
16760 KB |
Output is correct |
31 |
Correct |
19 ms |
16760 KB |
Output is correct |
32 |
Correct |
16 ms |
16760 KB |
Output is correct |
33 |
Execution timed out |
2027 ms |
38220 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
16764 KB |
Output is correct |
2 |
Correct |
22 ms |
16760 KB |
Output is correct |
3 |
Correct |
22 ms |
16760 KB |
Output is correct |
4 |
Correct |
22 ms |
16760 KB |
Output is correct |
5 |
Correct |
22 ms |
16760 KB |
Output is correct |
6 |
Correct |
22 ms |
16760 KB |
Output is correct |
7 |
Correct |
23 ms |
16760 KB |
Output is correct |
8 |
Correct |
16 ms |
16760 KB |
Output is correct |
9 |
Correct |
16 ms |
16760 KB |
Output is correct |
10 |
Correct |
16 ms |
16760 KB |
Output is correct |
11 |
Correct |
16 ms |
16760 KB |
Output is correct |
12 |
Correct |
16 ms |
16760 KB |
Output is correct |
13 |
Correct |
19 ms |
16760 KB |
Output is correct |
14 |
Correct |
16 ms |
16760 KB |
Output is correct |
15 |
Correct |
16 ms |
16688 KB |
Output is correct |
16 |
Correct |
19 ms |
16760 KB |
Output is correct |
17 |
Correct |
16 ms |
16760 KB |
Output is correct |
18 |
Correct |
16 ms |
16760 KB |
Output is correct |
19 |
Correct |
16 ms |
16760 KB |
Output is correct |
20 |
Correct |
16 ms |
16760 KB |
Output is correct |
21 |
Correct |
16 ms |
16760 KB |
Output is correct |
22 |
Correct |
16 ms |
16760 KB |
Output is correct |
23 |
Correct |
16 ms |
16760 KB |
Output is correct |
24 |
Correct |
16 ms |
16760 KB |
Output is correct |
25 |
Correct |
17 ms |
16760 KB |
Output is correct |
26 |
Correct |
16 ms |
16760 KB |
Output is correct |
27 |
Correct |
15 ms |
16764 KB |
Output is correct |
28 |
Correct |
16 ms |
16760 KB |
Output is correct |
29 |
Correct |
16 ms |
16760 KB |
Output is correct |
30 |
Correct |
16 ms |
16760 KB |
Output is correct |
31 |
Correct |
19 ms |
16760 KB |
Output is correct |
32 |
Correct |
16 ms |
16760 KB |
Output is correct |
33 |
Execution timed out |
2027 ms |
38220 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |