답안 #256954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256954 2020-08-03T12:53:41 Z kimbj0709 Calvinball championship (CEOI15_teams) C++14
100 / 100
204 ms 760 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000007
#define maxn 10050
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int n;
  int input;
  cin >> n;
  vector<int> vect1(n+1);
  vector<int> prefix(n+1,0);
  for(int i=1;i<=n;i++){
    cin >> vect1[i];
    prefix[i] = vect1[i];
  }
  for(int i=1;i<prefix.size();i++){
    prefix[i] = max(prefix[i],prefix[i-1]);
  }
  int dp[2][maxn];
  for(int i=1;i<n;i++){
    dp[0][i] = 1;
  }
  int ans = 0;
  for(int i=1;i<n;i++){
    int curr = (i%2),bef = ((i-1)%2);
    for(int j=1;j<=n;j++){
      dp[curr][j] = j*dp[bef][j]+dp[bef][j+1];
      dp[curr][j] %= mod;
    }
    ans += (vect1[n-i]-1)*dp[curr][prefix[n-i-1]];
    ans %= mod;
  }
  ans += vect1[n];
  ans %= mod;
  cout << ans;
}

Compilation message

teams.cpp: In function 'int32_t main()':
teams.cpp:19:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<prefix.size();i++){
               ~^~~~~~~~~~~~~~
teams.cpp:11:7: warning: unused variable 'input' [-Wunused-variable]
   int input;
       ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 408 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 200 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 568 KB Output is correct
2 Correct 57 ms 568 KB Output is correct
3 Correct 53 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 201 ms 640 KB Output is correct
2 Correct 204 ms 760 KB Output is correct
3 Correct 198 ms 640 KB Output is correct