Submission #813179

#TimeUsernameProblemLanguageResultExecution timeMemory
813179OrazBBoxes with souvenirs (IOI15_boxes)C++14
20 / 100
1 ms308 KiB
#include <bits/stdc++.h> // #include "boxes.h" using namespace std; #define all(x) (x).begin(), (x).end() #define ll long long int #define pii pair <int, int> #define pb push_back #define ff first #define ss second // const int N = 1e5+5; ll delivery(int n, int K, int L, int p[]){ if (K == 1){ ll sum = 0; for (int i = 0; i < n; i++){ sum += min(p[i], L-p[i])*2; } return sum; } const ll inf = 1e18; ll mn = min({L, p[n-1]*2, (L-p[0])*2}); for (int i = 0; i < n-1; i++){ ll sum = min(L, p[i]*2)*1LL+min(L, (L-p[i+1])*2)*1LL; mn = min(mn, sum); } return mn; } // int main () // { // ios::sync_with_stdio(false); // 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); // }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:21:11: warning: unused variable 'inf' [-Wunused-variable]
   21 |  const ll inf = 1e18;
      |           ^~~
#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...