답안 #231675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231675 2020-05-14T11:33:38 Z BamiTorabi Calvinball championship (CEOI15_teams) C++14
100 / 100
403 ms 632 KB
//Sasayego! Sasayego! Shinzou wo Sasageyo!

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e4 + 5;
const ll INF = 1e18;
const ll MOD = 1e6 + 7;

int a[maxN], mx[maxN], dp[maxN];

int main(){
	time_t START = clock();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		scanf("%d", a + i);
		mx[i] = max(mx[i - 1], a[i]);
		dp[i] = 1;
	}
	ll ans = 0;
	for (int i = n; i; i--){
		ans = (ans + 1ll * (a[i] - 1) * dp[mx[i - 1]]) % MOD;
		for (int j = 1; j <= n; j++)
			dp[j] = (0ll + dp[j + 1] + 1ll * j * dp[j] % MOD) % MOD;
	}
	printf("%lld\n", ans + 1);
	time_t FINISH = clock();
	cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
	return 0;
}
 

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d", &n);
         ~~~~~^~~~~~~~~~
teams.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a + i);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 403 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 504 KB Output is correct
2 Correct 104 ms 468 KB Output is correct
3 Correct 103 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 383 ms 632 KB Output is correct
2 Correct 374 ms 512 KB Output is correct
3 Correct 374 ms 512 KB Output is correct