QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#378085#5058. Prof. Pang Earning AusInfinityNSTL 4ms3956kbC++171.3kb2024-04-06 00:34:272024-04-06 00:34:28

Judging History

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

  • [2024-04-06 00:34:28]
  • 评测
  • 测评结果:TL
  • 用时:4ms
  • 内存:3956kb
  • [2024-04-06 00:34:27]
  • 提交

answer

#include<bits/stdc++.h>

#define f first
#define s second
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()

using namespace std;

vector<ll> x(6);
vector<int> n(2),k(6);
ll ans;
void pok(){
    x[0]=(n[0]-x[5]*k[5])/k[0];
    if(x[0]<0)return;
    x[1]=x[0]*k[0]+x[5]*k[5]-x[4];
    if(x[1]<0)return;
    x[2]=(n[1]-x[4]*k[4])/k[2];
    if(x[2]<0)return;
    x[3]=x[2]*k[2]+x[4]*k[4]-x[5];
    if(x[3]<0)return;
    if(x[0]==0&&x[2]==0)return;
    if(x[1]+x[4]>n[0])return;
    if(x[3]+x[5]>n[1])return;
    ans=max(ans,x[1]*k[1]+x[3]*k[3]-x[0]-x[2]);
}
vector<int> x4,x5;
void test(){
    for(int i=0;i<2;i++){
        scanf("%i",&n[i]);
    }
    for(int i=0;i<6;i++){
        scanf("%i",&k[i]);
    }
    ans=0;
    const int L=100;
    for(x[4]=0;x[4]<=L;x[4]++)x4.pb(x[4]);
    for(x[5]=0;x[5]<=L;x[5]++)x5.pb(x[5]);
    int mx4=min(n[1]/k[4],n[0]),mx5=min(n[0]/k[5],n[1]);
    for(x[4]=mx4;x[4]>=0&&mx4-x[4]<=L;x[4]--)x4.pb(x[4]);
    for(x[5]=mx5;x[5]>=0&&mx5-x[5]<=L;x[5]--)x5.pb(x[5]);
    for(auto p:x4)for(auto q:x5){
        x[4]=p;
        x[5]=q;
        pok();
    }
    printf("%lld\n",ans+1);
}

int main(){
    int t;
    scanf("%i",&t);
    while(t--){
        test();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 3956kb

input:

6
2 2 2 2 2 2 2 2
78 74 5 3 10 2 4 7
31 75 3 6 6 1 8 4
91 86 4 2 9 5 8 5
48 89 3 9 2 3 5 7
13 25 5 7 6 1 2 4

output:

7
355
239
571
637
109

result:

ok 6 numbers

Test #2:

score: -100
Time Limit Exceeded

input:

1000
10 10 7 9 8 3 3 10
3 7 3 10 3 3 6 5
8 1 4 7 1 10 1 5
7 7 3 10 4 7 2 9
7 9 6 7 3 3 4 6
9 2 4 4 9 5 2 4
8 1 9 1 2 3 7 3
6 4 7 9 8 5 6 2
10 2 4 8 6 9 6 1
9 7 2 10 10 4 7 1
5 4 5 6 8 7 10 5
4 4 7 7 1 5 3 8
4 5 8 9 5 10 1 7
2 6 10 9 2 4 10 6
7 3 8 9 3 9 5 4
2 7 6 1 5 8 5 6
3 5 9 3 6 2 9 9
9 9 8 3 6 ...

output:


result: