답안 #152675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152675 2019-09-09T06:47:53 Z toloraia Calvinball championship (CEOI15_teams) C++17
20 / 100
247 ms 1148 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
//#pragma comment(linker, "/STACK: 20000000005")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

const ll N = 1e4 + 5, MOD = 1e9 + 7;

int n;
int a[N];

vector < pair < int, ll > > V[N];

ll ans;
ll dp[N];

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int mx = 1;
    ans = a[n];
    for (int i = 2; i < n; i++){
        if (a[i] == 1)
            continue;
        V[n - i].pb ({mx, a[i] - 1});
        mx = max (mx, a[i]);
    }
    for (int i = 0; i <= n; i++)
        dp[i] = 1;
    for (int i = 1; i <= n; i++){
        for (ll j = 0; j <= n; j++)
            dp[j] = (dp[j + 1] + j * dp[j]) % MOD;
        for (int j = 0; j < V[i].size(); j++){
            int x = V[i][j].F;
            ll y = V[i][j].S;
            ans = (ans + y * dp[x]) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Compilation message

teams.cpp:17:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
teams.cpp:18:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
teams.cpp:31:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
teams.cpp: In function 'int main()':
teams.cpp:51:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < V[i].size(); j++){
                         ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 247 ms 1092 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 205 ms 1148 KB Output isn't correct
2 Halted 0 ms 0 KB -