Submission #424528

#TimeUsernameProblemLanguageResultExecution timeMemory
424528cpp219Calvinball championship (CEOI15_teams)C++14
100 / 100
238 ms656 KiB
#pragma GCC optimization "O2" #pragma GCC optimization "unroll-loop" #pragma GCC target ("avx2") #include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; const ll N = 1e4 + 9; const ll mod = 1e6 + 7; typedef pair<ll,ll> LL; ll n,x,ans = 1,a[N],prv[N],dp[N]; ll mx[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define task "test" if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin>>n; memset(dp,-1,sizeof(dp)); for (ll i = 1;i <= n;i++) cin>>a[i],mx[i] = max(mx[i - 1],a[i]); ans += a[n] - 1; for (ll i = 1;i <= n;i++) dp[i] = i; for (ll i = n - 1;i > 0;i--){ for (ll i = 1;i <= n;i++) prv[i] = dp[i]; for (ll i = 1;i <= n;i++) dp[i] = ((i - 1)*prv[i] + prv[i + 1])%mod; ll x = a[i],now = mx[i - 1]; ans += (x - 1)*prv[now + 1]; ans %= mod; //cout<<(x - 1)*prv[now + 1]<<"x\n"; } cout<<ans; }

Compilation message (stderr)

teams.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization "O2"
      | 
teams.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
teams.cpp: In function 'int main()':
teams.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...