#37943: 為什麼會NA?


s010041@fjsh.cy.edu.tw (位數煌包哲)

學校 : 嘉義市私立輔仁高級中學
編號 : 214782
來源 : [163.27.10.248]
最後登入時間 :
2023-10-26 14:12:55

#include <iostream>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;

    int t[1000] = {0};
    int s[1000] = {0};

    int wrong, time = 0;
    int maximun = -1;

    //input array
    for(int i = 0; i<n; i++){
        cin >> t[i];
        cin >> s[i];
    }

    //count wrong
    for(int i = 0; i<n; i++){
        if(s[i] == -1){
            wrong++;
        }
    }

    //maximun
    for(int i = 0; i<n; i++){
        if(s[i] > maximun){
            maximun = s[i];
            time = i;
        }
    }

    int point = maximun - n - (wrong * 2);

    if(point >= 0){
        cout << point << " ";
    }else{
        cout << 0 << " ";
    }

    cout << t[time];

    return 0;
}

#37945: Re: 為什麼會NA?


liaoweichen1024@gmail.com (M_SQRT)

學校 : 新北市立新莊高級中學
編號 : 195452
來源 : [140.114.123.98]
最後登入時間 :
2025-09-24 19:10:46

#include

using namespace std;

int main()
{
    int n = 0;
    cin >> n;

    int t[1000] = {0};
    int s[1000] = {0};

    int wrong, time = 0;
    int maximun = -1;

    //input array
    for(int i = 0; i
        cin >> t[i];
        cin >> s[i];
    }

    //count wrong
    for(int i = 0; i
        if(s[i] == -1){
            wrong++;
        }
    }

    //maximun
    for(int i = 0; i
        if(s[i] > maximun){
            maximun = s[i];
            time = i;
        }
    }

    int point = maximun - n - (wrong * 2);

    if(point >= 0){
        cout << point << " ";
    }else{
        cout << 0 << " ";
    }

    cout << t[time];

    return 0;
}


wrong 沒給初始值