Submission #527348

# Submission time Handle Problem Language Result Execution time Memory
527348 2022-02-17T09:22:02 Z beepbeepsheep Calvinball championship (CEOI15_teams) C++17
70 / 100
358 ms 588 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define ll long long
#define ii pair<ll,ll>
#define endl '\n'
const ll inf=1e15;
const ll mod=1e6+7;
const ll maxn=10005;

int dp[maxn],nxt[maxn];
ll arr[maxn],pref[maxn];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,ele,ans=0;
    cin>>n;
    ll temp;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
        dp[i]=1;
        pref[i]=max(arr[i],pref[i-1]);
    }
    for (int i=n;i>=1;i--){
        for (int j=1;j<maxn-1;j++){
            nxt[j]=(dp[j]*(j))%mod+dp[j+1];
            nxt[j]%=mod;
        }
        for (int j=1;j<arr[i];j++){
            temp=max<ll>(j,pref[i-1]);
            ans+=dp[temp];
            ans%=mod;
        }
        swap(dp,nxt);
    }
    cout<<(ans+1)%mod;
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:17:10: warning: unused variable 'ele' [-Wunused-variable]
   17 |     ll n,ele,ans=0;
      |          ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 3 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 336 KB Output is correct
2 Correct 8 ms 332 KB Output is correct
3 Correct 9 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 332 KB Output is correct
2 Correct 15 ms 420 KB Output is correct
3 Correct 16 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 358 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 564 KB Output isn't correct
2 Halted 0 ms 0 KB -