제출 #978110

#제출 시각아이디문제언어결과실행 시간메모리
978110KasymK은행 (IZhO14_bank)C++17
0 / 100
1 ms560 KiB
#include "bits/stdc++.h"

using namespace std;

int n, m;
vector<int> a, b;

const int N = 1e3 + 4;
const int M = 20 + 5;

int dp[N][M];

bool f(int pos, int sum){
    if(~dp[pos][sum])
        return dp[pos][sum];
    if(pos == m){
        if(sum == a.front())
            return dp[pos][sum] = 1;
        return dp[pos][sum] = 0;
    }
    if(f(pos + 1, sum + b[pos]))
        return dp[pos][sum] = 1;
    if(f(pos + 1, sum))
        return dp[pos][sum] = 1;
    return dp[pos][sum] = 0;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    for(int &i : a)
        cin >> i;
    for(int &i : b)
        cin >> i;
    cout << (f(0, 0) ? "YES" : "NO") << "\n";
    return 0;
}

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

bank.cpp: In function 'bool f(int, int)':
bank.cpp:18:33: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   18 |             return dp[pos][sum] = 1;
      |                    ~~~~~~~~~~~~~^~~
bank.cpp:19:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   19 |         return dp[pos][sum] = 0;
      |                ~~~~~~~~~~~~~^~~
bank.cpp:22:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   22 |         return dp[pos][sum] = 1;
      |                ~~~~~~~~~~~~~^~~
bank.cpp:24:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   24 |         return dp[pos][sum] = 1;
      |                ~~~~~~~~~~~~~^~~
bank.cpp:25:25: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   25 |     return dp[pos][sum] = 0;
      |            ~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...