結果
問題 | No.1043 直列大学 |
ユーザー | hokto |
提出日時 | 2020-05-02 16:45:43 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,093 bytes |
コンパイル時間 | 2,184 ms |
コンパイル使用メモリ | 207,780 KB |
実行使用メモリ | 162,808 KB |
最終ジャッジ日時 | 2023-08-28 22:23:55 |
合計ジャッジ時間 | 11,568 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,384 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 142 ms
136,264 KB |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | WA | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | AC | 109 ms
98,844 KB |
testcase_22 | AC | 115 ms
103,580 KB |
testcase_23 | AC | 178 ms
159,396 KB |
testcase_24 | AC | 88 ms
80,904 KB |
testcase_25 | AC | 123 ms
111,316 KB |
testcase_26 | AC | 142 ms
128,496 KB |
testcase_27 | AC | 39 ms
36,660 KB |
testcase_28 | AC | 119 ms
108,980 KB |
testcase_29 | AC | 14 ms
13,816 KB |
testcase_30 | AC | 86 ms
77,692 KB |
ソースコード
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define MOD 1000000007 #define MAX_VR 1000 #define ll long long int using namespace std; int main() { int N,M; cin>>N>>M; vector<int> V(N); vector<int> R(M); sort(V.begin(),V.end()); sort(R.begin(),R.end()); rep(i,N) cin>>V[i]; rep(i,M) cin>>R[i]; int A,B; cin>>A>>B; vector<vector<ll>> dp_v(N+1,vector<ll>(N*MAX_VR+1,0)); vector<vector<ll>> dp_r(M+1,vector<ll>(M*MAX_VR+1,0)); dp_v[0][0]=1; dp_r[0][0]=1; rep(i,N) { for(int j=N*MAX_VR-V[i];j>=0;j--) { dp_v[i+1][j]+=dp_v[i][j]; dp_v[i+1][j+V[i]]+=dp_v[i][j]; dp_v[i+1][j]%=MOD; } } rep(i,M) { for(int j=M*MAX_VR-R[i];j>=0;j--) { dp_r[i+1][j]+=dp_r[i][j]; dp_r[i+1][j+R[i]]+=dp_r[i][j]; dp_r[i+1][j]%=MOD; } } vector<ll> alloc(N*MAX_VR+2,0); rep(i,N*MAX_VR+1) { alloc[i+1]=alloc[i]+dp_v[N][i]; } ll ans=0; for(int i=1;i<=M*MAX_VR;i++) { int max=B*i; if(max>N*MAX_VR)max=N*MAX_VR; int min=A*i; if(min>N*MAX_VR)min=N*MAX_VR; ans+=(alloc[max+1]-alloc[min])*dp_r[M][i]; ans%=MOD; } cout<<ans<<endl; return 0; }