# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
244449 | tqbfjotld | Calvinball championship (CEOI15_teams) | C++14 | 677 ms | 888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mem[10005][2][2];
int memb[2];
int n;
int MOD = 1000007LL;
int arr[10005];
int hbound[100005];
main(){
scanf("%lld",&n);
for (int x = 0; x<n; x++){
scanf("%lld",&arr[x]);
hbound[x] = x==0?1:max(hbound[x-1],arr[x]);
//printf("%lld\n",hbound[x]);
}
memset(mem,-1,sizeof(mem));
for (int x = n-1; x>=0; x--){
for (int high = 1; high<=x+1; high++){
for (int bound = 0; bound<1; bound++){
if (x == n-1){
mem[high][bound][0] = bound?arr[x]:high+1;
// printf("pos %lld high %lld bound %lld: %lld\n",x,high,bound,mem[high][bound][0]);
continue;
}
if (bound){
mem[high][bound][0] = mem[max(high,arr[x]-1)][0][1]*(arr[x]-1);
mem[high][bound][0] %= MOD;
mem[high][bound][0] += mem[max(high,arr[x])][1][1];
mem[high][bound][0] %= MOD;
}
else{
mem[high][bound][0] = high*mem[high][0][1];
mem[high][bound][0]%=MOD;
mem[high][bound][0] += mem[high+1][0][1];
mem[high][bound][0] %= MOD;
}
//printf("pos %lld high %lld bound %lld: %lld\n",x,high,bound,mem[high][bound][0]);
}
}
if (x==n-1){
memb[0] = arr[x];
}
else{
memb[0] = mem[x==0?0:hbound[x-1]][0][1]*(arr[x]-1);
//printf("test %lld\n",mem[x==0?0:hbound[x-1]][0][1]);
memb[0] %= MOD;
//printf("bound %lld %lld\n",x,memb[0]);
memb[0] += memb[1];
memb[0] %= MOD;
}
//printf("bound %lld %lld\n",x,memb[0]);
for (int h = 1; h<=x+1; h++){
mem[h][0][1] = mem[h][0][0];
mem[h][0][0] = 0;
}
memb[1] = memb[0];
memb[0] = 0;
// printf("memb1 %lld\n",memb[1]);
}
printf("%lld",memb[1]);
}
/*
1 1 1 1
1 1 1 2
1 1 2 1
1 1 2 2
1 1 2 3
1 2 1 1
1 2 1 2
1 2 1 3
1 2 2 1
1 2 2 2
1 2 2 3
1 2 3 1
1 2 3 2
1 2 3 3
1 2 3 4
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |