QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203101 | #2481. Pickpockets | Delay_for_five_minutes# | WA | 1ms | 5492kb | C++20 | 1.5kb | 2023-10-06 15:25:15 | 2023-10-06 15:25:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int h , T;
int c[100005];
int d[17] , I[17];
int f[17][1<<16];
int sum[1<<16] ;
int sumI[1<<16];
int main()
{
// freopen("in.txt","r",stdin) ;
ios::sync_with_stdio(false) ; cin.tie(0) ;cout.tie(0) ;
cin >> h >> T;
for(int i = 1;i <= h;i++) {
cin >> c[i];
if(c[i] > T) {
cout << 0 << '\n' ; return 0;
}
}
for(int i = 1;i <= T;i++) cin >> d[i] >> I[i] ;
vector<int> vs;
for(int i = T;i >= 1;i--) {
int lst = 1;
for(int j = 2;j <= h + 1;j++) {
if((c[j] >= i) != (c[j - 1] >= i) || j == h + 1) {
if(c[j - 1] >= i) {
vs.push_back(j - lst) ;
}
lst = j;
}
}
}
if(vs.size() > T) {
cout << 0 ; return 0;
}
for(int i = 1;i < (1<<T);i++) {
for(int j = 0;j < T;j++) {
if((i >> j) & 1) {
sum[i] = sum[i ^ (1<<j)]+d[j + 1] ;
sumI[i] = sumI[i ^ (1<<j)]+I[j+1];
break ;
}
}
}
for(int i = 1;i <= vs.size();i++) {
for(int j = 0;j < (1<<T);j++) {
for(int s = j ;s ; s = (s - 1) & j) { ///what I use
if(sum[s] == vs[i - 1]) {
f[i][j] = max(f[i][j] , f[i - 1][j ^ s] + sumI[s]) ;
}
}
}
}
int ans = 0;
for(int i = 0;i < (1<<T);i++) ans = max(ans , f[vs.size()][i]) ;
cout << ans ; return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3432kb
input:
2 2 1 2 1 5 2 5
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5492kb
input:
2 2 1 2 2 5 1 5
output:
10
result:
ok single line: '10'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
3 4 2 1 2 3 2 1 1 1 2 1 3
output:
7
result:
ok single line: '7'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
1 5 2 1 2 1 5 1 3 1 5 1 3
output:
10
result:
ok single line: '10'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
1 5 1 1 2 1 1 1 2 1 5 1 2
output:
5
result:
ok single line: '5'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3360kb
input:
1 7 0 1 5 1 5 1 5 1 2 1 5 1 3 1 6
output:
0
result:
ok single line: '0'
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 5484kb
input:
3 6 2 1 1 2 1 3 5 2 3 3 3 2 4 3 3
output:
5
result:
wrong answer 1st lines differ - expected: '0', found: '5'