Submission #810868

# Submission time Handle Problem Language Result Execution time Memory
810868 2023-08-06T16:56:52 Z JakobZorz Calvinball championship (CEOI15_teams) C++14
20 / 100
7 ms 8148 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <cstring>
#include <sstream>
 
#pragma GCC target("popcnt")
 
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
typedef pair<ll,ll>point;
//#define x first
//#define y second

int n;
int arr[10000];
ll dp[1002][1002];
 
int main(){
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        arr[i]--;
    }
    
    for(int teams=0;teams<=n+1;teams++)
        dp[n][teams]=1;
    
    for(int i=n-1;i>=0;i--){
        for(int teams=n+1;teams>=0;teams--){
            
            dp[i][teams]+=teams*dp[i+1][teams];
            dp[i][teams]+=dp[i+1][teams+1];
            
            dp[i][teams]%=MOD;
        }
    }
    
    ll res=1;
    
    int teams=0;
    for(int i=0;i<n;i++){
        teams=max(teams,arr[i]);
        
        res+=(ll)arr[i]*dp[i+1][teams];
        res%=MOD;
    }
    
    cout<<res<<"\n";
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 8148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -