QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602178#8936. Team Arrangementracxa#WA 0ms3596kbC++171.1kb2024-09-30 20:44:572024-09-30 20:44:59

Judging History

This is the latest submission verdict.

  • [2024-09-30 20:44:59]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3596kb
  • [2024-09-30 20:44:57]
  • Submitted

answer

#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
vector <int> c(61);

vector <vector <int>> v(61);

ll rec(ll n, ll i, priority_queue <int> st, bool ch = true) {
    if(n == 0) return 0;
    if(n < i) return -1e18;
    while((!st.empty()) && st.top() < i ) {
        st.pop();
    }
    if(ch)for(int to : v[i]) st.push(to);
    ll mx = rec(n, i + 1, st, true);
    if(st.size() >= i) {
        for(int j = 1; j <= i; j++) {
            st.pop();
        }
       
        mx = max(rec(n - i, i, st, false) + c[i], mx);
    }
   // cout << n << ' ' << i << ' ' << mx << '\n';
    return mx;
}

int main() {
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        int l, r; cin >> l >> r;
        v[l].pb(r);
    }
    for(int i = 1; i <= n; ++i) cin >> c[i];
    priority_queue <int> x;
    ll v = rec(n, 1, x);
    if(v <=-1e10) cout << "impossible";
    else cout << v;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3596kb

input:

3
2 3
1 2
2 2
4 5 100

output:

100

result:

wrong answer 1st lines differ - expected: '9', found: '100'