Submission #623492

#TimeUsernameProblemLanguageResultExecution timeMemory
623492tekiBoxes with souvenirs (IOI15_boxes)C++11
20 / 100
1 ms304 KiB
#include <bits/stdc++.h> #ifndef LOCAL_DEBUG #include "boxes.h" #endif #define pb push_back #define MS(x,y) memset((x), (y), sizeof((x))) typedef long long ll; const ll MN = 1000000007; using namespace std; ll delivery (int n2, int k2, int l2, int pos2[]) { ll n,k,l,pos[n2]; n = n2, k = k2, l = l2; for (int i = 0; i<n; i++) pos[i] = pos2[i]; if (k == 1) { ll res = 0; for (int i = 0; i<n; i++) res += min(pos[i],l-pos[i])*2; return res; } if (k == n) { ll maxi = 0, mini = MN; for (int i = 0; i<n; i++) { maxi = max(maxi,pos[i]); mini = min(mini,pos[i]); } ll res1 = maxi*2; ll res2 = (l-mini)*2; ll res3 = MN; sort(pos,pos+n); for (int i = 0; i<n-1; i++) res3 = min(res3,pos[i]*2+(l-pos[i+1])*2); return min(min(res1,res2), min(res3,l)); } } #ifdef LOCAL_DEBUG int main() { #ifdef LOCAL_DEBUG fstream cin("in.txt"); #endif ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); } #endif

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
#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...