我是0分啊0分(悲),不知道原因,求求大佬教我改改

P1046 [NOIP2005 普及组] 陶陶摘苹果

Rotten @ 2023-11-05 23:31:12

#include<stdio.h>
int main()
{
    int chair=30;
    int height[9];
    scanf("%d %d %d %d %d %d %d %d %d %d",&height[0],&height[1],&height[2],&height[3],&height[4],&height[5],&height[6],&height[7],&height[8],&height[9]);
    int handmax;
    scanf("%d",&handmax);
    int n=0;
    int num=0;
    while(n<10){
    if(handmax+chair>=height[n]){
        num++;
        }
        n++;
    }
    printf("%d",num);
    return 0;
}

by SegmentTree_ @ 2023-11-05 23:32:28

height数组开小了


by cosf @ 2023-11-05 23:58:57

int height[10];

by cym_is_one_and_one @ 2023-11-06 00:37:56

其实这种一眼不会mle的完全可以开多一点数组


by Rotten @ 2023-11-06 16:13:54

@tianyu_awa @cym_is_one_and_one @cosf 谢谢佬,终于过了


|