QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624752#5303. No Bug No GameSingularityWA 92ms74172kbC++141.5kb2024-10-09 16:34:262024-10-09 16:34:27

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 16:34:27]
  • 评测
  • 测评结果:WA
  • 用时:92ms
  • 内存:74172kb
  • [2024-10-09 16:34:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define db double
const int N=3e5+5;
const int M=3e3+5;
const int INF=1e9+7;

int n,k;
struct node{
    int p;
    int w[M];
    db s;
}a[M];

bool cmp(node x,node y)
{
    if(abs(x.s-y.s)<1e-6)
        return x.p>y.p;
    else return x.s>y.s;
}

void solve()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i].p;
        for(int j=1;j<=a[i].p;j++){
            cin>>a[i].w[j];
        }
        a[i].s=(db)a[i].w[a[i].p]/(db)a[i].p;
    }
    sort(a+1,a+n+1,cmp);
    int ans=0;
    for(int i=1;i<=n;i++){
        int sum=0,sumw=0;
        int p=a[i].p;
        // cout<<"i "<<i<<" "<<p<<" "<<a[i].w[p]<<endl;
        for(int j=1;j<=n;j++){
            if(j==i) continue;
            if(sum+a[j].p>k) continue;
            if(sum+a[j].p==k){
                ans=max(ans,sumw+a[j].w[a[j].p]);
                continue;
            }
            sumw+=a[j].w[a[j].p];
            sum+=a[j].p;
            ans=max(ans,sumw);
            if(sum+p>k){
                // cout<<" j "<<a[j].p<<" "<<a[j].w[a[j].p]<<" "<<sum<<" "<<sumw<<endl;
                ans=max(ans,sumw+a[i].w[k-sum]);
                continue;
            }
            else ans=max(ans,sumw+a[i].w[p]);
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
/*
4 5
2 1 3
2 1 1
2 3 1
2 1 3
*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3872kb

input:

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

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Wrong Answer
time: 92ms
memory: 74172kb

input:

3000 3000
10 70562 30723 79371 82224 63977 3362 26909 96449 48163 66159
4 18007 33590 80674 91139
4 10304 31694 70745 50656
10 63090 17226 13187 73881 38137 15237 55750 82751 75854 39658
8 95640 66120 87735 36388 44046 92415 6952 94772
9 60565 27904 98726 87052 35768 25453 14563 34273 92501
10 66332...

output:

68279668

result:

wrong answer 1st numbers differ - expected: '68279788', found: '68279668'