# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40952 | wzy | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 604 ms | 21464 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <vector>
#include <stdint.h>
#include <algorithm>
using namespace std;
#define pb push_back
#define int long long
int ans = 1 , v1[50] , v2[50] , n , m;
int32_t main(){
scanf("%lld%lld" , &n , &m);
int sz1 = n / 2 , sz2 = n - sz1;
for(int i = 0 ; i < n;i++){
if(sz1){
scanf("%lld" , &v1[n/2 - sz1]);
sz1--;
}
else{
scanf("%lld" , &v2[(n - n/2) - sz2]);
sz2--;
}
}
vector<int> value1 , value2;
sz1 = n/2 , sz2 = n - sz1;
for(int i = 1 ; i < (1<<sz1) ; i++){
int sum = 0;
for(int j = 0 ; j < n ; j++){
if(1<<j & i) sum += v1[j];
}
if(sum <= m)
value1.pb(sum);
}
for(int i = 1 ; i < (1<<sz2) ; i++){
int sum = 0;
for(int j = 0 ; j < n ; j++){
if(1<<j & i) sum += v2[j];
}
if(sum <= m)
value2.pb(sum);
}
ans += value1.size() + value2.size();
sort(value1.begin() , value1.end());
sort(value2.begin() , value2.end());
for(int i = 0 ; i < value1.size() ; i++){
int l = 0 , r = (int)value2.size() - 1;
int ansj = -1;
while(l<= r){
int mid = (l+r)/2;
if(value2[mid] + value1[i] <= m){
l = mid + 1;
ansj = max(ansj , mid);
}
else r = mid - 1;
}
if(ansj != -1) ans += ansj + 1;
}
printf("%lld\n" , ans);
}
컴파일 시 표준 에러 (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... |