This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
using namespace std;
using ll=long long;
using ld=long double;
const ll MOD=1e9+7;
const ll MAX=1e5;
ll n;
ll dp[MAX+5][4];
int main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n;
for(int i=0; i<n; ++i){
ll a;
cin>>a;
dp[a][1]=(dp[a][1]+a)%MOD;
}
for(int i=1; i<=MAX; ++i){
for(int j=2; j<=3; ++j){
dp[i][j]=(dp[i-1][j]+dp[i-1][j-1]*dp[i][1])%MOD;
}
}
cout<<dp[MAX][3];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |