Submission #1017130

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10171302024-07-08 22:07:28davieduBank (IZhO14_bank)C++17
71 / 100
1080 ms8616 KiB
#include <stdio.h>
#include <string.h>
int dp[1<<20], r[1<<20];
int pay[20], notes[20];
int main(){
memset(dp, -1, sizeof(dp));
int n, m;
scanf("%d %d", &n, &m);
for (int i=0; i<n; i++) scanf("%d", &pay[i]);
for (int i=0; i<m; i++) scanf("%d", &notes[i]);
int ans=0;
for (int i=0; i<n; i++){
for (int mask=1; mask<(1<<m); mask++){
int p=-2;
int c=-1;
for (int j=0; j<m; j++){
if (mask & (1 << j)){
if (dp[mask ^ (1 << j)] > p){
p = dp[mask ^ (1 << j)];
c = j;
}
}
}
int d = mask ^ (1 << c);
int v = r[d] + notes[c];
if (dp[d] == i) dp[mask] = i, r[mask] = v;
else if (dp[d] == i-1){
if (v == pay[i]) dp[mask] = i, r[mask] = 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:11:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for (int i=0; i<n; i++) scanf("%d", &pay[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~
bank.cpp:12:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (int i=0; i<m; i++) scanf("%d", &notes[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...