結果
問題 | No.1043 直列大学 |
ユーザー | ngtkana |
提出日時 | 2020-05-01 22:52:32 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,870 bytes |
コンパイル時間 | 2,423 ms |
コンパイル使用メモリ | 205,704 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-07 11:14:48 |
合計ジャッジ時間 | 3,352 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 24 ms
5,376 KB |
testcase_13 | WA | - |
testcase_14 | AC | 12 ms
5,376 KB |
testcase_15 | AC | 13 ms
5,376 KB |
testcase_16 | AC | 11 ms
5,376 KB |
testcase_17 | AC | 7 ms
5,376 KB |
testcase_18 | WA | - |
testcase_19 | AC | 11 ms
5,376 KB |
testcase_20 | AC | 6 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 5 ms
5,376 KB |
testcase_28 | AC | 7 ms
5,376 KB |
testcase_29 | AC | 3 ms
5,376 KB |
testcase_30 | AC | 9 ms
5,376 KB |
ソースコード
#define ENABLE_DEBUG 1 // hidden common codes{{{ #include<bits/stdc++.h> #define ALL(v) std::begin(v),std::end(v) using lint=long long; using ld=long double; template<class T> using numr=std::numeric_limits<T>; struct input_t { template<class T> operator T() { T t; std::cin>>t; return t; } } input; #ifdef NGTKANA #include<debug.hpp> #else #define DEBUG(...)(void)0 #endif /*}}}*/ // mint {{{ template <class ModType> struct modint { using value_type = typename ModType::value_type; using mint = modint<ModType>; static value_type mod() { return ModType::value; } static value_type inverse(value_type x) { value_type y=1,u=mod(),v=0; while(x){ value_type q=u/x; u-=q*x; std::swap(x,u); v-=q*y; std::swap(y,v); } assert(x==0 && std::abs(y)==mod() && std::abs(u)==1 && std::abs(v)<mod()); return v<0?v+mod():v; } // the member variable value_type value; // constructors modint()=default; modint(modint const&)=default; modint(modint&&)=default; modint& operator=(modint const&)=default; modint& operator=(modint&&)=default; ~modint()=default; template <class T> modint(T t) : value([t] () mutable { if ( t <= -static_cast<T>(mod()) || static_cast<T>(mod()) <= t ) t %= mod(); return t < 0 ? t + mod() : t; }()) {} // operators mint& operator+= (mint y) { value += y.value; if (mod() <= value) value -= mod(); return *this; } mint& operator-= (mint y) { value -= y.value; if ( 0 < value ) value += mod(); return *this; } mint& operator*= (mint y) { value = (long long)value * y.value % mod(); return *this; } mint& operator/= (mint y) { value = (long long)value * inverse(y.value) % mod(); return *this; } mint& operator++() { return *this+=1; } mint& operator--() { return *this-=1; } mint& operator++(int) { mint this_=*this; *this++; return this_; } mint& operator--(int) { mint this_=*this; *this--; return this_; } // member functions mint& add(mint y) { return *this+=y; } mint& sub(mint y) { return *this-=y; } mint& mul(mint y) { return *this*=y; } mint& div(mint y) { return *this/=y; } mint& inv() { value = inverse(value); return *this; } mint added(mint y) { mint ans=*this; return ans.add(y); } mint subed(mint y) { mint ans=*this; return ans.sub(y); } mint muled(mint y) { mint ans=*this; return ans.mul(y); } mint dived(mint y) { mint ans=*this; return ans.div(y); } mint inved() { mint ans=*this; return ans.inv(); } static mint m1pow(long long y) { return y%2?-1:1; } static mint pow(mint x, unsigned long long y) { mint ans=1; for(;y;y>>=1){ if(y&1ull) ans*=x; x*=x; } return ans; } mint& powed(unsigned long long y){ return *this=pow(*this, y); } template <class F> mint map(F const& f){ value=f(value); return *this; } }; template <class T> std::ostream& operator<<(std::ostream& os, modint<T> x) { return os << x.value; } template <class T> modint<T> operator+(modint<T> x, modint<T> y) { return x+=y; } template <class T> modint<T> operator-(modint<T> x, modint<T> y) { return x-=y; } template <class T> modint<T> operator*(modint<T> x, modint<T> y) { return x*=y; } template <class T> modint<T> operator/(modint<T> x, modint<T> y) { return x/=y; } template <class T> bool operator==(modint<T> x, modint<T> y) { return x.value==y.value; } template <class T> bool operator!=(modint<T> x, modint<T> y) { return x.value!=y.value; } template <class T, class U> modint<T> operator+(modint<T> x, U y) { return x+modint<T>(y); } template <class T, class U> modint<T> operator-(modint<T> x, U y) { return x-modint<T>(y); } template <class T, class U> modint<T> operator*(modint<T> x, U y) { return x*modint<T>(y); } template <class T, class U> modint<T> operator/(modint<T> x, U y) { return x/modint<T>(y); } template <class T, class U> bool operator==(modint<T> x, U y) { return x==modint<T>(y); } template <class T, class U> bool operator!=(modint<T> x, U y) { return x!=modint<T>(y); } template <class T, class U> modint<T> operator+(U x, modint<T> y) { return modint<T>(x)+y; } template <class T, class U> modint<T> operator-(U x, modint<T> y) { return modint<T>(x)-y; } template <class T, class U> modint<T> operator*(U x, modint<T> y) { return modint<T>(x)*y; } template <class T, class U> modint<T> operator/(U x, modint<T> y) { return modint<T>(x)/y; } template <class T, class U> bool operator==(U x, modint<T> y) { return modint<T>(x)==y; } template <class T, class U> bool operator!=(U x, modint<T> y) { return modint<T>(x)!=y; } using mod_type = int; constexpr mod_type mod = 1'000'000'007; using mint = modint< std::integral_constant<mod_type, mod> >; //}}} int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); auto make=[&](auto&&a){ lint N=std::accumulate(ALL(a),0ll); std::vector<mint>dp(N+1,0); dp.at(0)=1; for(lint x:a){ for(lint i=N-x;i>=0;i--){ dp.at(i+x)+=dp.at(i); } } return dp; }; lint n=input,m=input; std::vector<lint>a(n),b(m); for(lint&x:a)x=input; for(lint&x:b)x=input; lint min=input,max=input; auto da=make(a),db=make(b); std::partial_sum(ALL(da),da.begin()); mint ans=0; for(lint j=1;j<(lint)db.size();j++){ if((lint)da.size()<=j*min)break; lint l=std::min(min*j, (lint)da.size()-1); lint r=std::min(max*j, (lint)da.size()-1); ans+=(da.at(r)-da.at(l-1))*db.at(j); } std::cout<<ans<<'\n'; }