Submission #3429168
Source Code Expand
#include <algorithm> #include <iostream> #include <vector> #include <math.h> #include <set> #include <map> #include <string> #include <stack> #include <queue> #include <iomanip> #include <numeric> #include <tuple> #include <bitset> #include <complex> #include <unistd.h> #include <cassert> #include <cctype> #include <random> #define _USE_MATH_DEFINES #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> plglg; typedef pair<double, ll> pdlg; typedef tuple<int, int, int> tiii; typedef tuple<ll, ll, ll> tlglglg; typedef tuple<double, double, double> tddd; typedef complex<double> xy_t; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; double pi = 3.141592653589793; ll mod = 1000000007; int intmax = 2147483647; int intmin = -2147483648; ll llmax = 9223372036854775807; ll llmin = -9223372036854775807; int iinf = intmax / 8; ll inf = llmax / 8; double eps = 1e-11; int main() { ll N, K; cin >> N >> K; ll A[N], B[N]; for (int i = 0; i < N; i++) { cin >> A[i] >> B[i]; } bool bit[30]; for (int i = 0; i < 30; i++) { if ((K & (1 << i)) > 0) { bit[i] = true; } else { bit[i] = false; } } ll sum[30]; fill(sum, sum + 30, 0); for (int i = 29; i >= 0; i--) { if (bit[i] || i == 0) { for (int j = 0; j < N; j++) { bool ok = true; for (int k = 29; k > i; k--) { if (!bit[k] && ((A[j] & (1 << k)) > 0)) { ok = false; } } if (i != 0) { if ((A[j] & (1 << i)) > 0) { ok = false; } } else { if (!bit[0] && (A[j] % 2 == 1)) { ok = false; } } if (ok) { sum[i] += B[j]; //cout << i << " " << j << endl; } } } } ll ans = 0; for (int i = 0; i < 30; i++) { ans = max(ans, sum[i]); } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - IntegerotS |
User | NMLibrary |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 2274 Byte |
Status | AC |
Exec Time | 161 ms |
Memory | 1792 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 100 ms | 1792 KB |
02.txt | AC | 109 ms | 1792 KB |
03.txt | AC | 119 ms | 1792 KB |
04.txt | AC | 113 ms | 1792 KB |
05.txt | AC | 113 ms | 1792 KB |
06.txt | AC | 112 ms | 1792 KB |
07.txt | AC | 108 ms | 1792 KB |
08.txt | AC | 108 ms | 1792 KB |
09.txt | AC | 110 ms | 1792 KB |
10.txt | AC | 114 ms | 1792 KB |
11.txt | AC | 114 ms | 1792 KB |
12.txt | AC | 114 ms | 1792 KB |
13.txt | AC | 125 ms | 1792 KB |
14.txt | AC | 125 ms | 1792 KB |
15.txt | AC | 114 ms | 1792 KB |
16.txt | AC | 112 ms | 1792 KB |
17.txt | AC | 120 ms | 1792 KB |
18.txt | AC | 100 ms | 1792 KB |
19.txt | AC | 118 ms | 1792 KB |
20.txt | AC | 115 ms | 1792 KB |
21.txt | AC | 123 ms | 1792 KB |
22.txt | AC | 114 ms | 1792 KB |
23.txt | AC | 107 ms | 1792 KB |
24.txt | AC | 98 ms | 1792 KB |
25.txt | AC | 115 ms | 1792 KB |
26.txt | AC | 125 ms | 1792 KB |
27.txt | AC | 113 ms | 1792 KB |
28.txt | AC | 119 ms | 1792 KB |
29.txt | AC | 116 ms | 1792 KB |
30.txt | AC | 128 ms | 1792 KB |
31.txt | AC | 118 ms | 1792 KB |
32.txt | AC | 124 ms | 1792 KB |
33.txt | AC | 107 ms | 1792 KB |
34.txt | AC | 107 ms | 1792 KB |
35.txt | AC | 112 ms | 1792 KB |
36.txt | AC | 113 ms | 1792 KB |
37.txt | AC | 115 ms | 1792 KB |
38.txt | AC | 106 ms | 1792 KB |
39.txt | AC | 115 ms | 1792 KB |
40.txt | AC | 110 ms | 1792 KB |
41.txt | AC | 100 ms | 1792 KB |
42.txt | AC | 111 ms | 1792 KB |
43.txt | AC | 105 ms | 1792 KB |
44.txt | AC | 102 ms | 1792 KB |
45.txt | AC | 101 ms | 1792 KB |
46.txt | AC | 104 ms | 1792 KB |
47.txt | AC | 152 ms | 1792 KB |
48.txt | AC | 161 ms | 1792 KB |
49.txt | AC | 84 ms | 1792 KB |
50.txt | AC | 62 ms | 1792 KB |
51.txt | AC | 1 ms | 256 KB |
52.txt | AC | 1 ms | 256 KB |
53.txt | AC | 1 ms | 256 KB |
54.txt | AC | 1 ms | 256 KB |
55.txt | AC | 1 ms | 256 KB |
56.txt | AC | 1 ms | 256 KB |
57.txt | AC | 1 ms | 256 KB |
58.txt | AC | 2 ms | 384 KB |
59.txt | AC | 1 ms | 256 KB |
60.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |