Submission #57056
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | //header{{{ #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define reps(i,n) for(int i=1;i<=(n);++i) #define all(x) (x).begin(),(x).end() #define setout(n,x) setw(n+1) << setfill(x) #define Fixed fixed << setprecision(10) #define int int64_t using pii = pair< int , int >; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int mod = 1e9+7; template < class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true ); } template < class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true ); } template < class T> using min_heap = priority_queue<T,vector<T>,greater<T> >; template < class T> using max_heap = priority_queue<T>; int gcd( int a, int b){ return b ? gcd(b,a % b) : a;} int lcm( int a, int b){ return a / gcd(a,b) * b;} //}}} signed main(){ cin.tie(0); ios::sync_with_stdio( false ); int N,Q; cin >> N >> Q; vector< int > a(N); rep(i,N){ cin >> a[i]; } sort(all(a)); a.erase(unique(all(a)),a.end()); vector< int > vec; int M = a.size(); for ( int bit = 0;bit < (1 << M);++bit){ int sum = 0; rep(i,M){ if (bit & (1 << i)) sum += a[i]; } vec.emplace_back(sum); } sort(all(vec)); rep(i,Q){ int x; cin >> x; if (*lower_bound(all(vec),x) == x) cout << "Possible\n" ; else cout << "Impossible\n" ; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 1217 - Properly Choosing |
ユーザー名 | ei1903 |
投稿日時 | 2019-12-09 23:45:49 |
言語 | C++14 |
状態 | Accepted |
得点 | 10 |
ソースコード長 | 1437 Byte |
最大実行時間 | 263 ms |
最大メモリ使用量 | 32892 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 10 / 10 | in* |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01-01.txt | AC | 32 ms | 600 KB |
1
|
in01-02.txt | AC | 16 ms | 616 KB |
1
|
in01-03.txt | AC | 20 ms | 688 KB |
1
|
in01-04.txt | AC | 28 ms | 1536 KB |
1
|
in01-05.txt | AC | 25 ms | 1872 KB |
1
|
in01-06.txt | AC | 30 ms | 2720 KB |
1
|
in01-07.txt | AC | 263 ms | 28628 KB |
1
|
in01-08.txt | AC | 259 ms | 29432 KB |
1
|
in01-09.txt | AC | 26 ms | 5428 KB |
1
|
in01-10.txt | AC | 27 ms | 6528 KB |
1
|
in01-11.txt | AC | 24 ms | 7500 KB |
1
|
in01-12.txt | AC | 256 ms | 32892 KB |
1
|
in02-01.txt | AC | 22 ms | 8376 KB |
1
|
in02-02.txt | AC | 30 ms | 9480 KB |
1
|
in02-03.txt | AC | 23 ms | 10584 KB |
1
|
in02-04.txt | AC | 24 ms | 10660 KB |
1
|
in02-05.txt | AC | 76 ms | 19564 KB |
1
|
in02-06.txt | AC | 74 ms | 20532 KB |
1
|
in02-07.txt | AC | 90 ms | 21624 KB |
1
|
in02-08.txt | AC | 95 ms | 22688 KB |
1
|
in02-09.txt | AC | 172 ms | 32044 KB |
1
|
in02-10.txt | AC | 94 ms | 24804 KB |
1
|
sample01.txt | AC | 19 ms | 17060 KB | |
sample02.txt | AC | 23 ms | 17020 KB |