답안 #957675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957675 2024-04-04T07:44:23 Z hariaakas646 Calvinball championship (CEOI15_teams) C++14
100 / 100
162 ms 632 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;


void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

const lli mod = 1000007;

lli dpl[2][10010];

int main() {
    // usaco();
    int n;
    scd(n);

    vi vec(n+1);
    frange(i, n) scd(vec[i+1]);

    frange(i, n+1) {
        dpl[0][i] = dpl[1][i] = 0;
    }

    int ma = 0;

    forr(i, 1, n+1) {
        forr(j, 1, n+1) {
            dpl[1][j] = (dpl[0][j-1] + dpl[0][j] * j) % mod;
        }
        if(vec[i] > ma) {
            dpl[1][ma] += ma;
            dpl[1][ma] %= mod;
            forr(j, ma+1, vec[i]) {
                dpl[1][j]++;
                dpl[1][j] %= mod;
            }
            ma = vec[i];
        }
        else {
            dpl[1][ma] += vec[i]-1;
            dpl[1][ma] %= mod;
        }
        forr(j, 0, n+1) dpl[0][j] = dpl[1][j]; 
    }
    lli tot = 0;

    forr(i, 1, n+1) tot += dpl[0][i];
    tot %= mod;
    printf("%lld", (tot+1)%mod);
}

Compilation message

teams.cpp: In function 'void usaco()':
teams.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp: In function 'int main()':
teams.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
teams.cpp:41:5: note: in expansion of macro 'scd'
   41 |     scd(n);
      |     ^~~
teams.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
teams.cpp:44:18: note: in expansion of macro 'scd'
   44 |     frange(i, n) scd(vec[i+1]);
      |                  ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 348 KB Output is correct
2 Correct 40 ms 344 KB Output is correct
3 Correct 40 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 604 KB Output is correct
2 Correct 158 ms 632 KB Output is correct
3 Correct 159 ms 604 KB Output is correct