Submission #1227723
Source Code Expand
#include <cstdio> #include <vector> #include <string> #include <algorithm> using namespace std; #define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i)) #define rep(i,n) reps(i,0,n) int N,M,q; const int MOD = 1e9+7; const int MAX_N = 110; const int MAX_M = 110; int main(){ scanf("%d %d %d",&N,&M,&q); if(( N > 100 || M > 100 || q > 100)){ return 0; } vector<int> a(N,0); rep(i,N) scanf("%d", &a[i]); int dp[MAX_N][MAX_M+1] = {0}; int S[MAX_M+1] = {0}; while(q--){ int k, x; scanf("%d %d",&k,&x); k--; memset(dp,0,sizeof(dp)); dp[0][0] = 1; int m = M-x; rep(i,N){ if(i == k){ rep(j,m+1) dp[i+1][j] = dp[i][j]; continue; } rep(j,m+1) S[j+1] = (S[j] + dp[i][j]) % MOD; rep(j,m+1){ dp[i+1][j] = S[j+1] - S[max(0,j-a[i])]; dp[i+1][j] = (dp[i+1][j] + MOD) % MOD; } } printf("%d\n",dp[N][m]); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 注文の多い高橋商店 |
User | grun1396 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1116 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:33:31: error: ‘memset’ was not declared in this scope memset(dp,0,sizeof(dp)); ^ ./Main.cpp:17:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d %d",&N,&M,&q); ^ ./Main.cpp:24:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] rep(i,N) scanf("%d", &a[i]); ^ ./Main.cpp:31:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&k,&x); ^