Submission #60732

# Submission time Handle Problem Language Result Execution time Memory
60732 2018-07-24T15:39:20 Z Flugan42 Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
2 ms 504 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto a : x)
#define inf 1000000000000000000

ll n,cur,res,myL,k;
vi a;

long long find(ll h, ll v){
  if (h+v > n) return inf;
  ll l = n-h-v;
  res = ((l+k-1)/k)*myL;
  cur = h-1;
  while(cur >= 0){
    res += a[cur]*2;
    cur -= k;
  }
  cur = n-v;
  while (cur < n){
    res += (myL-a[cur])*2;
    cur += k;
  }
  return res;
}

long long delivery(int N, int K, int L, int p[]) {
  ll best = inf, n = N, myL = L, k = K;
  rep(i,0,N) {
    if (p[i] == 0) n--;
    else a.push_back(p[i]);
  }
  rep(h,0,n) rep(v,0,n) best = min(best, find(h,v));
  return best;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:36:18: warning: declaration of 'n' shadows a global declaration [-Wshadow]
   ll best = inf, n = N, myL = L, k = K;
                  ^
boxes.cpp:15:4: note: shadowed declaration is here
 ll n,cur,res,myL,k;
    ^
boxes.cpp:36:25: warning: declaration of 'myL' shadows a global declaration [-Wshadow]
   ll best = inf, n = N, myL = L, k = K;
                         ^~~
boxes.cpp:15:14: note: shadowed declaration is here
 ll n,cur,res,myL,k;
              ^~~
boxes.cpp:36:34: warning: declaration of 'k' shadows a global declaration [-Wshadow]
   ll best = inf, n = N, myL = L, k = K;
                                  ^
boxes.cpp:15:18: note: shadowed declaration is here
 ll n,cur,res,myL,k;
                  ^
boxes.cpp:36:25: warning: unused variable 'myL' [-Wunused-variable]
   ll best = inf, n = N, myL = L, k = K;
                         ^~~
boxes.cpp:36:34: warning: unused variable 'k' [-Wunused-variable]
   ll best = inf, n = N, myL = L, k = K;
                                  ^
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -