답안 #538444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538444 2022-03-17T01:21:33 Z Pichon5 Magneti (COCI21_magneti) C++17
10 / 110
7 ms 4820 KB
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define ll long long
#define F first
#define S second
#define mp make_pair
#define ii pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll MOD=1e9+7;
int n,l,x;
const int tam=10005;
ll dp[tam][50];
ll f(int pos , int cant){
    if(cant==0)return 1;
    if(pos>l)return 0;
    if(dp[pos][cant]!=-1)return dp[pos][cant];
    dp[pos][cant]=f(pos+1,cant)+f(pos+x,cant-1);
    dp[pos][cant]%=MOD;
    return dp[pos][cant];
}

ll fact(int n){
    ll res=1;
    for(int i=1;i<=n;i++){
        res*=i;
        res%=MOD;
    }
    return res;
}
int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n>>l;
    for(int i=0;i<n;i++){
        cin>>x;
    }
    cout<<f(1,n)*fact(n)%MOD<<endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4820 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 4 ms 4692 KB Output is correct
4 Correct 3 ms 4820 KB Output is correct
5 Correct 3 ms 4308 KB Output is correct
6 Correct 7 ms 4692 KB Output is correct
7 Correct 2 ms 4436 KB Output is correct
8 Correct 3 ms 4308 KB Output is correct
9 Correct 2 ms 4436 KB Output is correct
10 Correct 2 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4820 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 4 ms 4692 KB Output is correct
4 Correct 3 ms 4820 KB Output is correct
5 Correct 3 ms 4308 KB Output is correct
6 Correct 7 ms 4692 KB Output is correct
7 Correct 2 ms 4436 KB Output is correct
8 Correct 3 ms 4308 KB Output is correct
9 Correct 2 ms 4436 KB Output is correct
10 Correct 2 ms 4308 KB Output is correct
11 Incorrect 4 ms 4732 KB Output isn't correct
12 Halted 0 ms 0 KB -