Submission #898673

# Submission time Handle Problem Language Result Execution time Memory
898673 2024-01-05T02:09:28 Z math_rabbit_1028 Fibonacci representations (CEOI18_fib) C++14
15 / 100
4000 ms 1344 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

int n, arr[101010];

ll dp[101010];
void solve(vector<int> vec) {
    sort(vec.begin(), vec.end());
    int k = vec.size();



    for (int i = 0; i <= k; i++) dp[i] = 0;

    dp[0] = 1;
    dp[1] = (vec[1] + 1) / 2;
    for (int i = 2; i <= k; i++) {
        ll d = vec[i] - vec[i - 1];
        if (d % 2 == 0) dp[i] = (dp[i-1] * ((d+3)/2) % MOD + MOD - dp[i-2]) % MOD;
        else dp[i] = dp[i-1] * ((d+1)/2) % MOD;
    }

    cout << dp[k-1] << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> arr[i];

    vector<int> vec(1, 0);
    for (int i = 1; i <= n; i++) {
        vec.push_back(arr[i]);
        solve(vec);
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Execution timed out 4086 ms 1344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -