提交记录 9800


用户 题目 状态 得分 用时 内存 语言 代码长度
GavinZheng noi19c. 【NOI2019】序列 Time Limit Exceeded 20 1 s 549120 KB C++11 1.67 KB
提交时间 评测时间
2019-07-16 14:14:09 2020-08-01 01:52:28
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
ll n,k,l;
struct gg {
    ll va,id;
}a[20],b[20],aa[20],bb[20];
int cnt=0;
ll mx=0;
bool cop(gg x,gg y){return x.va>y.va;}
int main() {
  //  freopen("sequence.in","r",stdin);
   // freopen("sequence.out","w",stdout);
    int t;scanf("%d",&t);
    for(int y=1;y<=t;y++) {
        mx=0;
        scanf("%lld%lld%lld", &n, &k, &l);
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &a[i].va);
            a[i].id = i;aa[i]=a[i];
        }
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &b[i].va);
            b[i].id = i;bb[i]=b[i];
        }
        sort(a + 1, a + n + 1, cop);
        sort(b + 1, b + n + 1, cop);

        for (int i = 1; i < (1ll << n); i++) {
            cnt = 0;
            for (int j = 0; j < n; j++) {
                if ((1ll << (j)) & i) {
                    cnt++;
                }
            }
            if (cnt != l)continue;
            int flag[20] = {0};
            ll tot = 0;
            for (int j = 0; j < n; j++) {
                if ((1ll << (j)) & i) {
                    flag[j + 1] = 1;
                    tot += aa[j + 1].va;
                    tot += bb[j + 1].va;
                }
            }
            int cnt1 = 0, cnt2 = 0;
            for (int j = 1; j <= n && (cnt1 != k - l || cnt2 != k - l); j++) {
                //if (flag[a[j].id])continue;
                if (cnt1 != k - l&&!flag[a[j].id])tot += a[j].va, cnt1++;
                if (cnt2 != k - l&&!flag[b[j].id])tot += b[j].va, cnt2++;
            }
            mx=max(mx,tot);
        }
        printf("%lld\n", mx);
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #154.31 us36 KBAcceptedScore: 4

Testcase #2445.08 us36 KBAcceptedScore: 4

Testcase #3426.54 us36 KBAcceptedScore: 4

Testcase #413.7 ms36 KBAcceptedScore: 4

Testcase #595.809 ms36 KBAcceptedScore: 4

Testcase #61 s536 MB + 256 KBTime Limit ExceededScore: 0

Testcase #737.21 us32 KBRuntime ErrorScore: 0

Testcase #864.45 us32 KBRuntime ErrorScore: 0

Testcase #962.27 us32 KBRuntime ErrorScore: 0

Testcase #1063.05 us32 KBRuntime ErrorScore: 0

Testcase #1163.59 us32 KBRuntime ErrorScore: 0

Testcase #1263.29 us32 KBRuntime ErrorScore: 0

Testcase #1363.07 us32 KBRuntime ErrorScore: 0

Testcase #1462.88 us32 KBRuntime ErrorScore: 0

Testcase #1563.56 us32 KBRuntime ErrorScore: 0

Testcase #1663.3 us32 KBRuntime ErrorScore: 0

Testcase #1762.7 us32 KBRuntime ErrorScore: 0

Testcase #1863.07 us32 KBRuntime ErrorScore: 0

Testcase #1964.37 us32 KBRuntime ErrorScore: 0

Testcase #2063.79 us32 KBRuntime ErrorScore: 0

Testcase #2163.05 us32 KBRuntime ErrorScore: 0

Testcase #2263.28 us32 KBRuntime ErrorScore: 0

Testcase #2364.47 us32 KBRuntime ErrorScore: 0

Testcase #2462.96 us32 KBRuntime ErrorScore: 0

Testcase #2563.95 us32 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-03 17:14:29 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠