# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40213 | evpipis | San (COCI17_san) | C++98 | 653 ms | 52664 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
pair<ll, ll> a[25], b[25];
vector<ll> vec[25];
int main(){
int n, m;
ll k;
scanf("%d %lld", &n, &k);
m = n-n/2;
n = n/2;
for (int i = 0; i < n; i++)
scanf("%lld %lld", &a[i].fi, &a[i].se);
for (int i = 0; i < m; i++)
scanf("%lld %lld", &b[i].fi, &b[i].se);
ll ans = 0;
for (int bit = 0; bit < (1<<n); bit++){
ll cur = 0;
int pos = -1, can = 1;
for (int i = 0; i < n; i++)
if (bit & (1<<i)){
if (pos != -1 && a[pos].fi > a[i].fi){
can = 0;
break;
}
pos = i;
cur += a[i].se;
}
for (int i = 0; i < m && pos != -1 && can; i++)
if (a[pos].fi <= b[i].fi)
vec[i].pb(cur);
if (pos == -1)
for (int i = 0; i < m; i++)
vec[i].pb(0LL);
if (cur >= k && can) ans++;
}
for (int i = 0; i < m; i++)
sort(vec[i].begin(), vec[i].end());
//printf("%d %d\n", vec[0].size(), vec[1].size());
for (int bit = 1; bit < (1<<m); bit++){
ll cur = 0;
int pos = -1, can = 1, fir = -1;
for (int i = 0; i < m; i++)
if (bit & (1<<i)){
//printf("now %d is on\n", i);
if (pos != -1 && b[pos].fi > b[i].fi){
can = 0;
break;
}
pos = i;
if (fir == -1) fir = i;
cur += b[i].se;
}
//printf("cur == %lld\n", cur);
if (can)
ans += vec[fir].end()-lower_bound(vec[fir].begin(), vec[fir].end(), k-cur);
}
printf("%lld\n", ans);
return 0;
}
컴파일 시 표준 에러 (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... |