이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Telebe of adicto yani AzeTurk810
/*
Author: AzeTurk810
Licance: open source(only authors name must be in code)
Begin Time:11/20/2024 20:48
Problem link: https://codeforces.com/problemset/problem/1543/D1
________ ________ _______ _________ ___ ___ ________ ___ __ ________ _____ ________
|\ __ \|\_____ \|\ ___ \|\___ ___\\ \|\ \|\ __ \|\ \|\ \ |\ __ \ / __ \|\ __ \
\ \ \|\ \\|___/ /\ \ __/\|___ \ \_\ \ \\\ \ \ \|\ \ \ \/ /|\ \ \|\ \|\/_|\ \ \ \|\ \
\ \ __ \ / / /\ \ \_|/__ \ \ \ \ \ \\\ \ \ _ _\ \ ___ \ \ __ \|/ \ \ \ \ \\\ \
\ \ \ \ \ / /_/__\ \ \_|\ \ \ \ \ \ \ \\\ \ \ \\ \\ \ \\ \ \ \ \|\ \ \ \ \ \ \\\ \
\ \__\ \__\\________\ \_______\ \ \__\ \ \_______\ \__\\ _\\ \__\\ \__\ \_______\ \ \__\ \_______\
\|__|\|__|\|_______|\|_______| \|__| \|_______|\|__|\|__|\|__| \|__|\|_______| \|__|\|_______|
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <map>
using namespace std;
using ll= long long;
using ull=unsigned long long;
# define vint vector<int>
//# define endl '\n'
# define range(a,b,c) for(int i=a;i<b;i+=c)
# define arange(a,b,c) for(int i=a;i>b;i-=c)
# define bend(x) (x).begin(),(x).end()
# define pb push_back
# define fori(x) for(int i=0;i<x;i++)
# define forj(y) for(int j=0;j<y;j++)
# define forn(x,c) for(int i=0;i<n;i+=c)
# define ff first
# define ss second
# define INF 1e9 + 7
# define printfprs(v) for(int alma = 0;alma<(v).size();alma++){cout<<(v)[alma].ff<< ' '<<(v)[alma].ss<<endl;};
# define int long long
ll dfs(int index, ll currentSum, const vector<ll>& costs, ll M) {
if (currentSum > M) return 0;
if (index == costs.size()) return 1;
ll include = dfs(index + 1, currentSum + costs[index], costs, M);
ll exclude = dfs(index + 1, currentSum, costs, M);
return include + exclude;
}
signed main() {
int N;
ll M;
cin >> N >> M;
vector<ll> costs(N);
for (int i = 0; i < N; ++i) {
cin >> costs[i];
}
ll totalWays = dfs(0, 0, costs, M);
cout << totalWays << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
bobek.cpp: In function 'll dfs(long long int, ll, const std::vector<long long int>&, ll)':
bobek.cpp:53:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | if (index == costs.size()) return 1;
| ~~~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |