# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
714075 | mseebacher | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 2644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define MAXI (int)1e5
#define pb(x) push_back(x)
vector<int> ad[MAXI];
vector<bool> vis(MAXI,0);
void dfs(int x){
if(vis[x]) return;
vis[x] = 1;
for(auto s:ad[x]){
dfs(s);
}
}
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
ll pref(int n,int k,int l,int pos[],int pre){
ll ans = 0;
for(int i = k-1;i<pre;i+=k){
ans += pos[i] + min(pos[i],l-pos[i]);
}
if(pre%k != 0)ans += pos[pre-1] + min(pos[pre-1],l-pos[pre-1]);
cout << ans << " ";
return ans;
}
ll suff(int n,int k,int l,int pos[],int pre){
ll ans = 0;
for(int i = n-k;i>=pre;i-=k){
ans += (l-pos[i]) + min(pos[i],l-pos[i]);
}
if((n-pre)%k != 0)ans += l-pos[pre] + min(pos[pre],l-pos[pre]);
cout << ans << " ";
return ans;
}
ll delivery(int n,int k,int l,int pos[]){
ll ans = 1e18;
for(int i = 0;i<=n;i++){
ans = min(ans,pref(n,k,l,pos,i)+suff(n,k,l,pos,i));
cout << "\n";
}
return ans;
}
Compilation message (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... |