답안 #890600

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890600 2023-12-21T14:55:52 Z Cookie Žarulje (COI15_zarulje) C++14
22 / 100
33 ms 34396 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define sz(a) (int)a.size()
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mpp make_pair
const ld PI = 3.14159265359;
using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 7;
const int mxn = 3e5 + 69, mxq = 1e5 + 5, sq = 500, mxv = 2e7 + 5;
//const int base = (1 << 18);
const int inf = 1e9 + 5, neg = -69420;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int x[9] = {0, 1, 1, -1, -1, 2, -2, 2, -2};
//const int y[9] = {0, 2, -2, 2, -2, 1, 1, -1, -1};
int n, k;
int power[mxn + 1], dp[2005][2005];
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("recruit.inp", "r", stdin);
    //freopen("recruit.out", "w", stdout);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)cin >> power[i];
    dp[0][n] = dp[1][n + 1] = 1;
    for(int len = n; len >= 1; len--){
        for(int j = 0; j + len - 1 <= n + 1; j++){
            int l = j, r = j + len - 1;
            if(r == n + 1)dp[l][r] = dp[l - 1][r];
            else if(l == 0)dp[l][r] = dp[l][r + 1];
            else{
                if(power[l] == power[r]){
                    dp[l][r] = (dp[l - 1][r] + dp[l][r + 1]) % mod;
                }else if(power[l] > power[r]){
                    dp[l][r] = dp[l - 1][r];
                }else{
                    dp[l][r] = dp[l][r + 1];
                }
            }
        }
    }
    while(k--){
        int p; cin >> p;
        ll ans = dp[p - 1][p + 1];
        cout << ans << "\n";
    }
    return(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 4 ms 10844 KB Output is correct
3 Correct 13 ms 16988 KB Output is correct
4 Correct 13 ms 17080 KB Output is correct
5 Correct 13 ms 17076 KB Output is correct
6 Correct 13 ms 16988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 33 ms 34396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 4 ms 10844 KB Output is correct
3 Correct 13 ms 16988 KB Output is correct
4 Correct 13 ms 17080 KB Output is correct
5 Correct 13 ms 17076 KB Output is correct
6 Correct 13 ms 16988 KB Output is correct
7 Runtime error 33 ms 34396 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -