Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
using namespace std; const int maxn = 1005; typedef long long ll; const ll MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); int n, K; cin >> n >> K; vector
v(n); for(int i = 0; i < n; i++) { cin >> v[i]; } vector
dp(K + 1); dp[0] = 1; for(int at = 0; at < n; at++) { for(int used_candies = K; used_candies >= 0; used_candies--) { ll tmp = dp[used_candies]; int L = used_candies + 1; int R = used_candies + min(v[at], K - used_candies); for(int i = L; i <= R; i++) { dp[i] += tmp; dp[i] %= MOD; } // for(int candy = 1; candy <= min(v[at], K - used_candies); candy++) { // dp[used_candies + candy] += tmp; // dp[used_candies + candy] %= MOD; // } } } cout << dp[K] << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)