Submission #127298

#TimeUsernameProblemLanguageResultExecution timeMemory
127298ekremBoxes with souvenirs (IOI15_boxes)C++98
100 / 100
1188 ms293732 KiB
#include "boxes.h" #include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define sol (k+k) #define sag (k+k+1) #define orta ((bas+son)/2) #define coc g[node][i] #define mod 1000000007 #define inf 1000000009 #define N 11000005 using namespace std; typedef long long ll; typedef pair < int , int > ii; ll n, k, l, cvp, ans, bas[N], son[N]; ll ansver(ll i, ll j){ // j = min(j, n); return ((i>=0)?bas[i]:0ll) + son[j] + 1ll*(j - i - 1 + k - 1)/k*l; } ll delivery(int nn, int kk, int ll, int p[]) {k = kk;l = ll;n = nn; for(int i = 0; i < n; i++) bas[i] = (i - k >= 0) ? bas[i - k] + p[i]*2ll : p[i]*2ll; for(int i = n - 1; i >= 0; i--) son[i] = (n > k + i) ? son[i + k] + (l - p[i])*2ll : (l - p[i])*2ll; cvp = ans = son[0]; int opt = 0; for(int i = -1; i < n; i++){ // cvp = son[0]; // opt = 0; int bas = 0, son = (n - i - 1)/n + 1; while(bas < son){ if(ansver(i, i + 1 + orta*k) >= ansver(i, i + 1 + k + orta*k)) bas = orta + 1; else son = orta; } // for(int j = i + 1; j <= n; j += k){ // cout << i << " " << j << " = " << ansver(i, j) << endl; // if(ansver(i, j) < cvp){ // cvp = ansver(i, j); // opt = j; // } // } // cout << endl << endl; // cout << i << " " << opt << " " << cvp << endl; ans = min(ans, ansver(i, i + 1 + orta*k)); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:26:44: warning: declaration of 'll' shadows a global declaration [-Wshadow]
 ll delivery(int nn, int kk, int ll, int p[]) {k = kk;l = ll;n = nn;
                                            ^
boxes.cpp:16:19: note: shadowed declaration is here
 typedef long long ll;
                   ^~
boxes.cpp:29:16: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  for(int i = n - 1; i >= 0; i--)
              ~~^~~
boxes.cpp:36:7: warning: declaration of 'bas' shadows a global declaration [-Wshadow]
   int bas = 0, son = (n - i - 1)/n + 1;
       ^~~
boxes.cpp:19:23: note: shadowed declaration is here
 ll n, k, l, cvp, ans, bas[N], son[N];
                       ^~~
boxes.cpp:36:16: warning: declaration of 'son' shadows a global declaration [-Wshadow]
   int bas = 0, son = (n - i - 1)/n + 1;
                ^~~
boxes.cpp:19:31: note: shadowed declaration is here
 ll n, k, l, cvp, ans, bas[N], son[N];
                               ^~~
boxes.cpp:36:36: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
   int bas = 0, son = (n - i - 1)/n + 1;
                      ~~~~~~~~~~~~~~^~~
boxes.cpp:32:6: warning: unused variable 'opt' [-Wunused-variable]
  int opt = 0;
      ^~~
#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...