답안 #549333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
549333 2022-04-15T15:38:43 Z krit3379 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
497 ms 8636 KB
#include<bits/stdc++.h>
using namespace std;
#define N 1005

long long k,c,sum,ans;
vector<long long> a,b,v;

int main(){
    int n,i,j;
    scanf("%d %lld",&n,&k);
    for(i=1;i<=n/2;i++)scanf("%lld",&c),a.push_back(c);
    n-=n/2;
    for(i=1;i<=n;i++)scanf("%lld",&c),b.push_back(c);
    n=a.size();
    for(i=0;i<1<<n;i++){
        sum=0;
        for(j=0;j<n;j++){
            if(i&(1<<j))sum+=a[j];
        }
        v.push_back(sum);
    }
    sort(v.begin(),v.end());
    n=b.size();
    for(i=0;i<1<<n;i++){
        sum=0;
        for(j=0;j<n;j++){
            if(i&(1<<j))sum+=b[j];
        }
        ans+=upper_bound(v.begin(),v.end(),k-sum)-v.begin();
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %lld",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:11:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(i=1;i<=n/2;i++)scanf("%lld",&c),a.push_back(c);
      |                        ~~~~~^~~~~~~~~~~
bobek.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(i=1;i<=n;i++)scanf("%lld",&c),b.push_back(c);
      |                      ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 936 KB Output is correct
2 Correct 93 ms 2420 KB Output is correct
3 Correct 497 ms 8616 KB Output is correct
4 Correct 93 ms 2504 KB Output is correct
5 Correct 15 ms 848 KB Output is correct
6 Correct 7 ms 596 KB Output is correct
7 Correct 14 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 1356 KB Output is correct
2 Correct 35 ms 848 KB Output is correct
3 Correct 185 ms 4548 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 7 ms 596 KB Output is correct
6 Correct 16 ms 944 KB Output is correct
7 Correct 14 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 1356 KB Output is correct
2 Correct 149 ms 2376 KB Output is correct
3 Correct 149 ms 2460 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 84 ms 2504 KB Output is correct
6 Correct 215 ms 8600 KB Output is correct
7 Correct 79 ms 2504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 325 ms 4492 KB Output is correct
2 Correct 28 ms 848 KB Output is correct
3 Correct 10 ms 596 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 9 ms 700 KB Output is correct
6 Correct 165 ms 4440 KB Output is correct
7 Correct 14 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 848 KB Output is correct
2 Correct 90 ms 2448 KB Output is correct
3 Correct 9 ms 596 KB Output is correct
4 Correct 10 ms 596 KB Output is correct
5 Correct 103 ms 2504 KB Output is correct
6 Correct 19 ms 940 KB Output is correct
7 Correct 242 ms 8536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 8636 KB Output is correct
2 Correct 32 ms 848 KB Output is correct
3 Correct 9 ms 596 KB Output is correct
4 Correct 483 ms 8608 KB Output is correct
5 Correct 121 ms 4516 KB Output is correct
6 Correct 14 ms 924 KB Output is correct
7 Correct 28 ms 1356 KB Output is correct