Submission #1018673

# Submission time Handle Problem Language Result Execution time Memory
1018673 2024-07-10T08:16:03 Z VarTech Bank (IZhO14_bank) C++17
0 / 100
2 ms 348 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long


signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
 
    
    int n, k; cin>>n>>k;
    int a[n];
    for (int i = 0; i < n; i++)
        cin>>a[i];
    pair<int, int> dp[1<<n];
    dp[0] = {0, k+1};
    for (int s = 1; s < (1<<n); s++) {
        dp[s] = {25, 0};
        for (int i = 0; i < n; i++) {
            if (s>>i&1){
                auto [c, w] = dp[s^(1<<i)];
                if (w + a[i] > k) {
                    c++;
                    w = min(a[i], w);
                }
                else
                    w += a[i];
                dp[s] = min(dp[s], {c, w});
            }
        }
  
    }
    cout<<dp[(1<<n)-1].first;
}

Compilation message

bank.cpp: In function 'int main()':
bank.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen("input.txt", "r" , stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -