CSP_Sept @ 2020-03-08 10:38:27
没吸氧50吸氧85
#include <cstdio>
#include <iostream>
using namespace std;
int n;
int a1,a2,a3,minn;
bool flag=1;
int main(){
freopen("order.in","r",stdin);
freopen("order.out","w",stdout);
scanf("%d",&n);
for(int a=0;a<n/7;a++){
for(int b=0;b<n/4;b++){
int c=(n-a*7-b*4)/3;
if(7*a+4*b+3*c==n&&flag) flag=0,a1=a,a2=b,a3=c,minn=min(min(a,b),c);
else if(7*a+4*b+3*c==n&&!flag){
if(min(min(a,b),c)>minn) a1=a,a2=b,a3=c,minn=min(min(a,b),c);
else if(min(min(a,b),c)==minn){
if(a+b+c>a1+a2+a3) a1=a,a2=b,a3=c,minn=min(min(a,b),c);
}
}
}
}
if(!flag) printf("%d %d %d",a1,a2,a3);
else printf("-1");
return 0;
}
思路就是用 -1
,符合条件的挨个比较。
by Hexarhy @ 2020-03-08 10:49:25
@CSP_Sept 我说了吧
因为我发现本地跑1e5可以过,再考虑评测效率,卡卡常凭借优异的常数就能把