제출 #1257631

#제출 시각아이디문제언어결과실행 시간메모리
1257631hickwhither은행 (IZhO14_bank)C++17
100 / 100
95 ms8644 KiB
#define mocua(inp, out) if(fopen(inp,"r")){freopen(inp,"r",stdin);freopen(out,"w",stdout);}

#include <iostream>
#include <cstdint>
#include <climits>

#include <cstring>

using namespace std;

const int LOG = (1<<20);
int logN, logM;

int n, m;
int salary[23], note[23];

int covered[LOG];
int miss[LOG];

signed main()
{
    cin.tie(0) -> sync_with_stdio(0);
    mocua("TABLE.INP", "TABLE.OUT");

    cin >> n >> m;
    logN = (1<<n);
    logM = (1<<m);
    for(int i=0; i<n; ++i) cin >> salary[i];
    for(int i=0; i<m; ++i) cin >> note[i];

    memset(covered, -1, sizeof covered);
    memset(miss, -1, sizeof miss);
    covered[0] = miss[0] = 0;

    for(int mask=1, old; mask<logM; ++mask){
        for(int i=0; i<m; ++i)if(mask>>i&1){
            old = mask^(1<<i);
            if(covered[old]==-1)continue;
            
            int val = miss[old]+note[i]; 
            int tar = salary[covered[old]];
            
            if(val < tar){
                covered[mask] = covered[old];
                miss[mask] = val;
            }
            else if(val==tar){
                covered[mask] = covered[old]+1;
                miss[mask] = 0;
            }

            if(covered[mask]==n){cout<<"YES"; return 0;}
        }
    }
    cout << "NO";

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:1:51: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    1 | #define mocua(inp, out) if(fopen(inp,"r")){freopen(inp,"r",stdin);freopen(out,"w",stdout);}
      |                                            ~~~~~~~^~~~~~~~~~~~~~~
bank.cpp:23:5: note: in expansion of macro 'mocua'
   23 |     mocua("TABLE.INP", "TABLE.OUT");
      |     ^~~~~
bank.cpp:1:74: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    1 | #define mocua(inp, out) if(fopen(inp,"r")){freopen(inp,"r",stdin);freopen(out,"w",stdout);}
      |                                                                   ~~~~~~~^~~~~~~~~~~~~~~~
bank.cpp:23:5: note: in expansion of macro 'mocua'
   23 |     mocua("TABLE.INP", "TABLE.OUT");
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...