# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171056 | Ruxandra985 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 488 ms | 8668 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/// un meet in the middle mai basic si mai penal decat mine
#include <bits/stdc++.h>
using namespace std;
long long v[45] , w[2000000];
int conf[45];
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , i , elem , st , dr , mid , p;
long long sol , m , sum;
fscanf (fin,"%d%lld",&n,&m);
for (i=1;i<=n;i++)
fscanf (fin,"%lld",&v[i]);
sum = 0;
elem = 0;
w[++elem] = 0; /// multimea vida
sol = 1;
while (true){
p = 1;
while (conf[p] == 1){
sum-=v[p];
conf[p] = 0;
p++;
}
if (p > n/2) /// 1 ... n/2
break;
conf[p] = 1;
sum += v[p];
if (sum <= m)
sol++;
w[++elem] = sum;
}
sort (w + 1 , w + elem + 1);
sum = 0;
conf[n/2+1] = 0;
while (true){
p = n/2 + 1; /// n/2 + 1 ... n
while (conf[p] == 1){
sum-=v[p];
conf[p] = 0;
p++;
}
if (p > n)
break;
conf[p] = 1;
sum += v[p];
st = 1;
dr = elem;
while (st <= dr){
mid = (st + dr)/2;
if (sum + w[mid] <= m)
st = mid + 1;
else dr = mid - 1;
}
sol += dr;
}
fprintf (fout,"%lld",sol);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |