#37943: 為什麼會NA?


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

學校 : 嘉義市私立輔仁高級中學
編號 : 214782
來源 : [163.27.10.248]
最後登入時間 :
2023-10-26 14:12:55
j605. 1. 程式考試 -- 2023年1月APCS | From: [42.76.118.113] | 發表日期 : 2023-10-20 08:10

#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
來源 : [210.71.71.103]
最後登入時間 :
2024-04-29 10:55:17
j605. 1. 程式考試 -- 2023年1月APCS | From: [163.20.230.153] | 發表日期 : 2023-10-20 13:23

#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 沒給初始值

 
ZeroJudge Forum