# APCS 2023年1月 實作1 - 程式考試 ## 題目敘述 https://zerojudge.tw/ShowProblem?problemid=j605 ## 程式碼 ```cpp= #include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int data[n][2]; for(int i=0; i<n; i++){ for(int j=0; j<2; j++){ cin >> data[i][j]; } } int max = -2; int time; int error = 0; for(int i=0; i<n; i++){ if(data[i][1] > max){ max = data[i][1]; time = data[i][0]; } if(data[i][1] == -1){ error++; } } int score = max-n-(2*error); if(score<0){ score = 0; } cout << score << " "; cout << time << endl; } ``` ## 執行結果 ![](https://i.imgur.com/EvXZN7v.png)