Submission #1179608
Source Code Expand
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
typedef pair<int, double> pid;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
int main(void){
int n[2], x; scanf("%d%d", &n[0], &x);
n[1] = n[0]-n[0]/2; n[0] = n[0]-n[1];
vector<vector<int>> w(2);
vector<vector<int>> v(2);
rep(i, n[0]){int t; scanf("%d", &t); w[0].push_back(t);}
rep(i, n[1]){int t; scanf("%d", &t); w[1].push_back(t);}
rep(i, 2) rep(j, 1<<n[i]){
int t = 0;
rep(l, n[i]) if((j>>l)&1) t += w[i][l];
v[i].push_back(t);
}
rep(i, 2) sort(v[i].begin(), v[i].end());
lli ans = 0;
rep(i, v[0].size()) ans += upper_bound(v[1].begin(), v[1].end(), x-v[0][i]) - lower_bound(v[1].begin(), v[1].end(), x-v[0][i]);
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 無駄なものが嫌いな人 |
User |
ktyshmt |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1409 Byte |
Status |
AC |
Exec Time |
21 ms |
Memory |
892 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:29:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int n[2], x; scanf("%d%d", &n[0], &x);
^
./Main.cpp:33:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i, n[0]){int t; scanf("%d", &t); w[0].push_back(t);}
^
./Main.cpp:34:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i, n[1]){int t; scanf("%d", &t); w[1].push_back(t);}
^
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
max_1.txt, max_2.txt, max_3.txt, max_4.txt, pair_1.txt, pair_2.txt, power2_1.txt, power2_2.txt, power2_3.txt, power2_4.txt, power2_5.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt |
Case Name |
Status |
Exec Time |
Memory |
max_1.txt |
AC |
14 ms |
892 KB |
max_2.txt |
AC |
16 ms |
892 KB |
max_3.txt |
AC |
14 ms |
892 KB |
max_4.txt |
AC |
16 ms |
892 KB |
pair_1.txt |
AC |
20 ms |
892 KB |
pair_2.txt |
AC |
17 ms |
892 KB |
power2_1.txt |
AC |
18 ms |
892 KB |
power2_2.txt |
AC |
17 ms |
892 KB |
power2_3.txt |
AC |
16 ms |
892 KB |
power2_4.txt |
AC |
16 ms |
892 KB |
power2_5.txt |
AC |
2 ms |
384 KB |
random_1.txt |
AC |
14 ms |
768 KB |
random_2.txt |
AC |
14 ms |
768 KB |
random_3.txt |
AC |
18 ms |
892 KB |
random_4.txt |
AC |
21 ms |
892 KB |
random_5.txt |
AC |
16 ms |
892 KB |
random_6.txt |
AC |
12 ms |
768 KB |
random_7.txt |
AC |
18 ms |
892 KB |
random_8.txt |
AC |
19 ms |
892 KB |
random_9.txt |
AC |
13 ms |
768 KB |
sample_1.txt |
AC |
1 ms |
256 KB |
sample_2.txt |
AC |
1 ms |
256 KB |
sample_3.txt |
AC |
1 ms |
256 KB |
sample_4.txt |
AC |
1 ms |
256 KB |
small_1.txt |
AC |
1 ms |
256 KB |
small_2.txt |
AC |
1 ms |
256 KB |
small_3.txt |
AC |
1 ms |
256 KB |
small_4.txt |
AC |
1 ms |
256 KB |