Why do I only get 95 points (WA on #14)

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

GoodLuckCat @ 2023-10-18 21:23:57

应该是没有考虑到最优解。所以这份代码怎么改?

95分记录

代码:

#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n==1||n==2||n==5){cout<<-1;return 0;}
    int a=n/14,b=n/14,c=n/14+n%14/3,m=n%14%3;n%=14;
    if(n==11){b+=2;c-=2;}
    else if(m==1){b++;c--;}
    else if(m==2){c+=3;a--;}
    cout<<a<<' '<<b<<' '<<c;
}

by pstdjr @ 2023-10-19 09:17:13

是不是没考虑全-1的情况


by GoodLuckCat @ 2023-10-19 12:31:05

@pstdjr 怎么改,我感觉已经考虑全了啊


by pstdjr @ 2023-10-19 23:17:07

错误样例:输入71


by GoodLuckCat @ 2023-10-23 21:43:27

@pstdjr AC了,谢谢


|