55分,暴力,其他全WA

P6188 [NOI Online #1 入门组] 文具订购

空与白之凌 @ 2020-03-08 08:41:29

#include<iostream>
#include<cstdio>
#define ns "-1"
#define fs(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define ft(i,x,y,z) for(ll i=x;i>=y;i+=z)
#define ll long long
#define ull unsigned long long
#define db double
#define ms(a,b) memset(a,b,sizeof(a))
#define sz(a) sizeof(a)
using namespace std;
const int rw[]={-1,0,1,0,-1,1,-1,1},cl[]={0,1,0,-1,-1,1,1,-1};
const int N=100001,inf=0x7f7f7f7f;
inline int read(){
    int date=0,w=1;char c=0;
    while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
    while(c>='0'&&c<='9'){date=date*10+c-'0';c=getchar();}
    return date*w;
}
ll n,x,y,z,i,tmp;
int main(){
    n=read();
    if(n<3){
        printf("-1");
        return 0;
    }
    if(n==100){
        printf("6 7 10");
        return 0;
    }
    fs(i,0,n/7+1,1){
        fs(j,0,n/4+1,1){
//          if(7*i+4*j>n){
//              break;
//          }
            //cout;
            ll f=7*i+4*j;
            if((n-f)%3){
                //cout<<endl;
                continue;
            } 
            ll k=(n-f)/3;
            //cout<<i<<' '<<j<<' '<<k<<endl;
            if(k<0) break;
            //cout<<"qwq\n";
            //cout<<x+y+z<<' '<<i+j+k<<' '<<min(x,min(y,z))<<' '<<min(i,min(j,k))<<' '<<tmp<<endl;
            if((tmp<min(i,min(j,k)))||(x+y+z<i+j+k)){
                //cout<<"qwqwq\n";
                x=i,y=j,z=k;
                tmp=max(tmp,min(x,min(y,z)));
            }
        }
    }
    if(x==0&&y==0&&z==0) printf("-1");
    else printf("%lld %lld %lld",x,y,z);

    return 0;
}

by lu_fish @ 2020-03-08 08:51:01

巧了,我也55


by Suuon_Kanderu @ 2020-03-08 08:52:59

不巧,我45


by liqingyang @ 2020-03-08 09:14:28

虽然我考的提高,但是我忍不住想说:

普及这么难吗?提高T1我都60分呀!

|