답안 #48058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48058 2018-05-09T16:37:00 Z Extazy Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
473 ms 9176 KB
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int N = 44;

int n,n2;
long long ans,m,a[N];
vector < long long > v;

void recurse1(int pos, long long sum) {
  if(pos>n2) {
    v.push_back(sum);
    return;
  }

  recurse1(pos+1,sum);
  recurse1(pos+1,sum+a[pos]);
}

void recurse2(int pos, long long sum) {
  if(pos>n) {
    ans+=(int)(upper_bound(v.begin(),v.end(),m-sum)-v.begin());
    return;
  }

  recurse2(pos+1,sum);
  recurse2(pos+1,sum+a[pos]);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i;

  scanf("%d %lld", &n, &m);
  for(i=1;i<=n;i++) {
    scanf("%lld", &a[i]);
  }

  n2=n/2;

  recurse1(1,0);
  sort(v.begin(),v.end());
  recurse2(n2+1,0);

  printf("%lld\n", ans);

  return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %lld", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &a[i]);
     ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 516 KB Output is correct
2 Correct 2 ms 536 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 556 KB Output is correct
6 Correct 2 ms 612 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 668 KB Output is correct
2 Correct 2 ms 668 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 2 ms 684 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 2 ms 704 KB Output is correct
3 Correct 2 ms 708 KB Output is correct
4 Correct 2 ms 712 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1368 KB Output is correct
2 Correct 94 ms 2896 KB Output is correct
3 Correct 416 ms 9032 KB Output is correct
4 Correct 85 ms 9032 KB Output is correct
5 Correct 11 ms 9032 KB Output is correct
6 Correct 6 ms 9032 KB Output is correct
7 Correct 9 ms 9032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 9032 KB Output is correct
2 Correct 27 ms 9032 KB Output is correct
3 Correct 170 ms 9032 KB Output is correct
4 Correct 2 ms 9032 KB Output is correct
5 Correct 5 ms 9032 KB Output is correct
6 Correct 10 ms 9032 KB Output is correct
7 Correct 10 ms 9032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 9032 KB Output is correct
2 Correct 150 ms 9032 KB Output is correct
3 Correct 158 ms 9032 KB Output is correct
4 Correct 2 ms 9032 KB Output is correct
5 Correct 44 ms 9032 KB Output is correct
6 Correct 152 ms 9096 KB Output is correct
7 Correct 55 ms 9096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 324 ms 9096 KB Output is correct
2 Correct 25 ms 9096 KB Output is correct
3 Correct 9 ms 9096 KB Output is correct
4 Correct 2 ms 9096 KB Output is correct
5 Correct 6 ms 9096 KB Output is correct
6 Correct 106 ms 9096 KB Output is correct
7 Correct 9 ms 9096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 9096 KB Output is correct
2 Correct 90 ms 9096 KB Output is correct
3 Correct 8 ms 9096 KB Output is correct
4 Correct 8 ms 9096 KB Output is correct
5 Correct 78 ms 9096 KB Output is correct
6 Correct 13 ms 9096 KB Output is correct
7 Correct 154 ms 9160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 352 ms 9168 KB Output is correct
2 Correct 35 ms 9168 KB Output is correct
3 Correct 9 ms 9168 KB Output is correct
4 Correct 473 ms 9176 KB Output is correct
5 Correct 112 ms 9176 KB Output is correct
6 Correct 10 ms 9176 KB Output is correct
7 Correct 18 ms 9176 KB Output is correct