Submission #171056

# Submission time Handle Problem Language Result Execution time Memory
171056 2019-12-27T09:00:42 Z Ruxandra985 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
488 ms 8668 KB
/// 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

bobek.cpp: In function 'int main()':
bobek.cpp:13:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d%lld",&n,&m);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
bobek.cpp:15:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%lld",&v[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 888 KB Output is correct
2 Correct 93 ms 2412 KB Output is correct
3 Correct 446 ms 8568 KB Output is correct
4 Correct 94 ms 2296 KB Output is correct
5 Correct 11 ms 760 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 10 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 1408 KB Output is correct
2 Correct 31 ms 888 KB Output is correct
3 Correct 180 ms 4600 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 10 ms 888 KB Output is correct
7 Correct 13 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 1400 KB Output is correct
2 Correct 161 ms 2424 KB Output is correct
3 Correct 155 ms 2416 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 41 ms 2552 KB Output is correct
6 Correct 146 ms 8568 KB Output is correct
7 Correct 53 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 352 ms 4572 KB Output is correct
2 Correct 25 ms 888 KB Output is correct
3 Correct 9 ms 632 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 110 ms 4472 KB Output is correct
7 Correct 10 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 760 KB Output is correct
2 Correct 88 ms 2452 KB Output is correct
3 Correct 8 ms 632 KB Output is correct
4 Correct 9 ms 504 KB Output is correct
5 Correct 77 ms 2296 KB Output is correct
6 Correct 14 ms 888 KB Output is correct
7 Correct 163 ms 8608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 354 ms 8568 KB Output is correct
2 Correct 34 ms 760 KB Output is correct
3 Correct 10 ms 760 KB Output is correct
4 Correct 488 ms 8668 KB Output is correct
5 Correct 68 ms 4472 KB Output is correct
6 Correct 10 ms 760 KB Output is correct
7 Correct 19 ms 1272 KB Output is correct