답안 #221903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221903 2020-04-11T13:36:15 Z MKopchev Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
389 ms 8576 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=50,MX=(1<<20)+42;

int n;
long long m,inp[nmax];

long long seen[MX];
int pointer=0;

long long output;

void dfs_1(int pos,int target,long long current)
{
    if(current>m)return;

    if(pos>target)
    {
        pointer++;
        seen[pointer]=current;
        return;
    }

    dfs_1(pos+1,target,current);

    dfs_1(pos+1,target,current+inp[pos]);
}

void dfs_2(int pos,int target,long long current)
{
    if(current>m)return;

    if(pos>target)
    {
        int pos=upper_bound(seen+1,seen+pointer+1,m-current)-seen;

        output=output+pos-1;

        return;
    }

    dfs_2(pos+1,target,current);

    dfs_2(pos+1,target,current+inp[pos]);
}

int main()
{
    scanf("%i%lld",&n,&m);

    for(int i=1;i<=n;i++)scanf("%lld",&inp[i]);

    dfs_1(1,n/2,0);

    sort(seen+1,seen+pointer+1);

    dfs_2(n/2+1,n,0);

    printf("%lld\n",output);
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~
bobek.cpp:51:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++)scanf("%lld",&inp[i]);
                          ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 432 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 896 KB Output is correct
2 Correct 80 ms 2424 KB Output is correct
3 Correct 361 ms 8568 KB Output is correct
4 Correct 76 ms 2424 KB Output is correct
5 Correct 11 ms 896 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 1400 KB Output is correct
2 Correct 28 ms 768 KB Output is correct
3 Correct 146 ms 4576 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 7 ms 512 KB Output is correct
6 Correct 12 ms 896 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 1400 KB Output is correct
2 Correct 122 ms 2428 KB Output is correct
3 Correct 121 ms 2424 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 39 ms 2432 KB Output is correct
6 Correct 141 ms 8576 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 4480 KB Output is correct
2 Correct 25 ms 888 KB Output is correct
3 Correct 11 ms 640 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 8 ms 640 KB Output is correct
6 Correct 113 ms 4480 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 896 KB Output is correct
2 Correct 77 ms 2336 KB Output is correct
3 Correct 10 ms 640 KB Output is correct
4 Correct 10 ms 512 KB Output is correct
5 Correct 50 ms 2424 KB Output is correct
6 Correct 15 ms 896 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 301 ms 8576 KB Output is correct
2 Correct 28 ms 896 KB Output is correct
3 Correct 11 ms 640 KB Output is correct
4 Correct 389 ms 8576 KB Output is correct
5 Correct 58 ms 4480 KB Output is correct
6 Correct 13 ms 896 KB Output is correct
7 Correct 4 ms 384 KB Output is correct