답안 #424509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
424509 2021-06-12T04:04:03 Z cpp219 Calvinball championship (CEOI15_teams) C++14
70 / 100
24 ms 16692 KB
#pragma GCC optimization "O2"
#pragma GCC optimization "unroll-loop"
#pragma GCC target ("avx2")

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 1e3 + 9;
const ll mod = 1e6 + 7;
typedef pair<ll,ll> LL;

ll n,x,dp[N][N],ans = 1;

ll f(ll pos,ll lim){
    if (pos == n + 1) return 1;
    if (pos == n) return lim;
    if (dp[pos][lim] != -1) return dp[pos][lim];
    ll ans = 0;
    ans = ((lim - 1)*f(pos + 1,lim)) % mod + f(pos + 1,lim + 1);
    ans %= mod;
    return dp[pos][lim] = ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define task "test"
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    cin>>n; memset(dp,-1,sizeof(dp));
    ll mx = 0; //cout<<f(3,2); return 0;
    for (ll i = 1;i <= n;i++){
        cin>>x;
        ans += (x - 1)*f(i + 1,mx + 1); ans %= mod;
        //cout<<(x - 1)*f(i + 1,mx + 1)<<"x\n";
        mx = max(mx,x);
    }
    cout<<ans;
}

Compilation message

teams.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization "O2"
      | 
teams.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
teams.cpp: In function 'int main()':
teams.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8268 KB Output is correct
2 Correct 4 ms 8268 KB Output is correct
3 Correct 4 ms 8268 KB Output is correct
4 Correct 4 ms 8268 KB Output is correct
5 Correct 5 ms 8240 KB Output is correct
6 Correct 4 ms 8268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8268 KB Output is correct
2 Correct 4 ms 8268 KB Output is correct
3 Correct 4 ms 8268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8268 KB Output is correct
2 Correct 4 ms 8268 KB Output is correct
3 Correct 4 ms 8268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8268 KB Output is correct
2 Correct 4 ms 8268 KB Output is correct
3 Correct 4 ms 8268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8268 KB Output is correct
2 Correct 6 ms 8268 KB Output is correct
3 Correct 5 ms 8300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8268 KB Output is correct
2 Correct 11 ms 8260 KB Output is correct
3 Correct 11 ms 8332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 16588 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 16656 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 16692 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -