답안 #314958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314958 2020-10-21T17:52:39 Z mohamedsobhi777 Calvinball championship (CEOI15_teams) C++14
10 / 100
2 ms 512 KB
#include <bits/stdc++.h>

#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")

#define I inline void
#define S struct
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;
using ll = long long;
using ld = long double;

const int N = 100 + 7, mod = 1e9 + 7;
const ll inf = 2e18;

// How interesting!

int n;
int a[N];
int Max;
int c[N][N];

int mul(int x, int y) { return 1ll * x * y % mod; }
int add(int x, int y) { return (x + y) >= mod ? x + y - mod : x + y; }

void nSr()
{
        c[0][0] = 1;
        for (int i = 1; i < N; ++i)
        {
                for (int j = 0; j <= i; ++j)
                {
                        if (i == j || !j)
                                c[i][j] = 1;
                        else
                                c[i][j] = add(c[i - 1][j - 1], mul(j, c[i - 1][j]));
                }
        }
}

int solve(int x, int y)
{
        int ret = 0;
        for (int i = y; i <= x; ++i)
                ret = add(ret, c[x][i]);
        return max(ret, 1);
}

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);
        nSr();
        cin >> n;
        int ans = 0;
        for (int i = 0; i < n; ++i)
        {
                int x;
                cin >> x;
                a[x] = 1;
                int sum = 0;
                for (int j = 1; j < x; ++j)
                {
                        sum += a[j];
                        ans += solve(n - i - 1, max(j, Max) - sum);
                }
                Max = max(Max, x);
        }
        cout << add(ans, 1);
        return 0;
}

/*
        - bounds sir (segtree = 4N, eulerTour = 2N, ...)
        - a variable defined twice?
        - will overflow?
        - is it a good complexity?
        - don't mess up indices (0-indexed vs 1-indexed)
        - reset everything between testcases. 
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -