QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#605049#8936. Team ArrangementPandaGhostWA 0ms3908kbC++141.3kb2024-10-02 15:13:552024-10-02 15:13:55

Judging History

This is the latest submission verdict.

  • [2024-10-02 15:13:55]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3908kb
  • [2024-10-02 15:13:55]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OPFI(x) freopen(#x".in", "r", stdin);\
                freopen(#x".out", "w", stdout)
#define REP(i, a, b) for(int i=(a); i<=(b); ++i)
#define REPd(i, a, b) for(int i=(a); i>=(b); --i)
inline ll rd(){
    ll r=0, k=1; char c; while(!isdigit(c=getchar())) if(c=='-') k=-k;
    while(isdigit(c)) r=r*10+c-'0', c=getchar(); return r*k;
}
ll n, w[70], ans=-LLONG_MAX/2;
#define MP make_pair
#define L first
#define R second
#define PII pair<int, int>
PII r[70];
vector<int> st;
int tmp[70];
void dfs(int s, int low){
    if(s==n){
        REP(i, 1, n) tmp[i]=0;
        for(int i:st) tmp[i]+=i;
        int j=1, flag=true;
        REP(i, 1, n){
            while(j<=n&&tmp[j]==0) ++j;
            if(r[i].L<=j&&j<=r[i].R) --tmp[j];
            else flag=false;
        }
        if(flag){
            ll sum=0;
            for(int i:st) sum+=w[i];
            ans=max(ans, sum);
        }
        return;
    }
    REP(i, low, n-s){
        st.push_back(i);
        dfs(s+i, i);
        st.pop_back();
    }
}
int main(){
    n=rd();
    REP(i, 1, n) r[i].L=rd(), r[i].R=rd();
    REP(i, 1, n) w[i]=rd();
    sort(r+1, r+n+1);
    dfs(0, 1);

    if(ans==-LLONG_MAX/2) puts("impossible");
    else printf("%lld\n", ans);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3796kb

input:

3
2 3
1 2
2 2
4 5 100

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

3
1 3
3 3
2 3
1 1 100

output:

100

result:

ok single line: '100'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

3
2 3
1 2
2 2
-100 -200 100000

output:

-300

result:

ok single line: '-300'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

9
1 4
2 5
3 4
1 5
1 1
2 5
3 5
1 3
1 1
1 1 1 1 1 1 1 1 1

output:

6

result:

ok single line: '6'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

14
3 3
1 2
2 3
2 3
2 3
1 1
2 3
1 3
3 3
1 3
1 3
1 2
2 3
1 3
-9807452 -9610069 4156341 2862447 6969109 -7245265 -2653530 -5655094 6467527 -6872459 3971784 7312155 9766298 -2719573

output:

-16558567

result:

ok single line: '-16558567'

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3908kb

input:

14
1 2
1 4
2 3
3 5
4 5
2 5
2 4
2 4
1 2
3 4
1 5
2 4
1 1
4 5
-13763 -7354207 1096407 -9063321 -4824546 -6275546 1258145 -5272834 -8631107 3581157 2320771 -7714508 8446625 -6816167

output:

-6925559

result:

wrong answer 1st lines differ - expected: '-2673021', found: '-6925559'