Submission #1121722

#TimeUsernameProblemLanguageResultExecution timeMemory
1121722vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
50 / 100
1085 ms387656 KiB
// 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 signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; int m; cin >>n>>m; vector<ll> costs(n); for (int i = 0; i < n; ++i) { cin >> costs[i]; } map<ll, ll> dp; dp[0] = 1; for (int i = 0; i < n; ++i) { map<ll, ll> newDp = dp; for (auto& [currentSum, count] : dp) { ll newSum = currentSum + costs[i]; if (newSum <= m) { newDp[newSum] += count; } } dp = newDp; } ll ans = 0; for (auto& [sum, count] : dp) { ans += count; } cout << ans << endl; return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...