Submission #90749

#TimeUsernameProblemLanguageResultExecution timeMemory
90749VinhspmCalvinball championship (CEOI15_teams)C++14
70 / 100
96 ms66560 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define FOR(a, b, c) for(int a = b; a <= c; ++a) #define pb push_back const int N = 1e5 + 10; const int mod = 1e6 + 7; int n, num; int a[N], cnt[N]; vector<int> f[N]; void add(int &x, int y) { x = (x + y) % mod; } signed main() { scanf("%d", &n); FOR(i, 1, n) scanf("%d", &a[i]); FOR(i, 0, n + 1) f[i].assign(i + 5, 0); FOR(i, 0, n) f[n + 1][i] = 1; for(int i = n; i >= 1; --i) FOR(j, 0, i) { add(f[i][j], f[i + 1][j] * j); add(f[i][j], f[i + 1][j + 1]); } int sum = 1; FOR(i, 1, n) { for(int j = 1; j < a[i]; ++j) { cnt[j] ++; if(cnt[j] == 1) num ++; add(sum, f[i + 1][num]); cnt[j] --; if(cnt[j] == 0) num --; } cnt[ a[i] ] ++; if(cnt[ a[i] ] == 1) num ++; } printf("%d", sum); }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:20:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     FOR(i, 1, n)    scanf("%d", &a[i]);
                     ~~~~~^~~~~~~~~~~~~
#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...