Submission #937621

#TimeUsernameProblemLanguageResultExecution timeMemory
937621danikoynovBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2 ms2396 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll inf = 1e18; const int maxn = 1e7 + 10; int n, k; ll p[maxn], temp[maxn]; ll L; ll get_price_left(int x) { ll res = 0; int t = 0; for (int i = 0; i < x; i ++) { //t ++; //if (t == x || t % k == 0) res = res + 2 * p[i]; } return res; } ll get_price_right(int x) { ll res = 0; int t = 0; for (int i = n - 1; i >= n - x; i --) { //t ++; //if (t == x || t % k == 0) res = res + 2 * (L - p[i]); } return res; } long long delivery(int N, int K, int _L, int P[]) { for (int i = 0; i < N; i ++) p[i] = P[i]; sort(p, p + N); n = N; k = K; L = _L; ll ans = 0; for (int i = 0; i < N; i ++) { ans = ans + 2 * min(p[i], L - p[i]); } //cout << get_price_right(1) << endl; ///exit(0); ll res = inf; for (int i = 0; i < N; i ++) { ll val = get_price_left(i) + get_price_right(N - i); //cout << i << " " << val << endl; res = min(res, val); //if (N - i - k >= 0) //{ // val = get_price_left(i) + get_price_right(N - i - k) + L; //res = min(res, val); //} } return res; }

Compilation message (stderr)

boxes.cpp: In function 'll get_price_left(int)':
boxes.cpp:16:9: warning: unused variable 't' [-Wunused-variable]
   16 |     int t = 0;
      |         ^
boxes.cpp: In function 'll get_price_right(int)':
boxes.cpp:29:9: warning: unused variable 't' [-Wunused-variable]
   29 |     int t = 0;
      |         ^
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:41:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   41 |     for (int i = 0; i < N; i ++)
      |     ^~~
boxes.cpp:43:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   43 |         sort(p, p + N);
      |         ^~~~
#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...