# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
810973 | 2023-08-06T18:46:57 Z | JakobZorz | Calvinball championship (CEOI15_teams) | C++14 | 727 ms | 1012 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=1e6+7; typedef pair<ll,ll>point; //#define x first //#define y second int n; int arr[10000]; ll dp[2][20000][2]; 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=-1;teams<=n;teams++){ dp[1][teams+1][0]=1; dp[1][teams+1][1]=1; } for(int i=n-1;i>=0;i--){ for(int teams=-1;teams<20000;teams++){ { ll res=0; res+=(teams+1)*dp[1][teams+1][0]; res+=dp[1][teams+2][0]; res%=MOD; dp[0][teams+1][0]=res; } { ll res=0; res+=min(teams+1,arr[i])*dp[1][teams+1][0]; if(teams>=arr[i]) res+=dp[1][teams+1][1]; if(teams+1<=arr[i]) res+=dp[1][teams+2][teams+1==arr[i]]; res%=MOD; dp[0][teams+1][1]=res; } } memcpy(dp[1],dp[0],20000*2*sizeof(ll)); } cout<<dp[0][0][1]<<"\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 852 KB | Output is correct |
2 | Correct | 1 ms | 852 KB | Output is correct |
3 | Correct | 1 ms | 852 KB | Output is correct |
4 | Correct | 1 ms | 852 KB | Output is correct |
5 | Correct | 1 ms | 852 KB | Output is correct |
6 | Correct | 1 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 852 KB | Output is correct |
2 | Correct | 1 ms | 852 KB | Output is correct |
3 | Correct | 1 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 852 KB | Output is correct |
2 | Correct | 2 ms | 852 KB | Output is correct |
3 | Correct | 2 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 852 KB | Output is correct |
2 | Correct | 7 ms | 852 KB | Output is correct |
3 | Correct | 7 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 936 KB | Output is correct |
2 | Correct | 35 ms | 932 KB | Output is correct |
3 | Correct | 35 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 71 ms | 944 KB | Output is correct |
2 | Correct | 69 ms | 936 KB | Output is correct |
3 | Correct | 69 ms | 940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 712 ms | 980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 348 ms | 968 KB | Output is correct |
2 | Correct | 342 ms | 952 KB | Output is correct |
3 | Correct | 372 ms | 972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 690 ms | 980 KB | Output is correct |
2 | Correct | 684 ms | 980 KB | Output is correct |
3 | Correct | 727 ms | 1012 KB | Output is correct |