#32630: c++解


j812018@nehs.hc.edu.tw (嗨)

學校 : 國立科學工業園區實驗高級中學
編號 : 152750
來源 : [101.10.45.143]
最後登入時間 :
2023-01-19 22:25:33
i428. 1. 巴士站牌 -- 2022年10月APCS | From: [36.227.121.96] | 發表日期 : 2022-10-24 19:38

#include<vector>
#include<math.h>
#include<algorithm>
#include <iostream>
using namespace std;

int main() {
    vector<int> x;
    vector<int> y;
    vector<int> ans;
    int a;
    cin >>a;
    for(int i=0;i<a;++i){
        int xx,yy;
        cin >>xx>>yy;
        x.push_back(xx);
        y.push_back(yy);

    }
    for(int i=0;i<a-1;++i){
        int temp;
        temp =abs(x[i]-x[i+1])+abs(y[i]-y[i+1]);
        ans.push_back(temp);
    }
    sort(ans.begin(), ans.end());

    cout<<ans[a-2]<<" "<<ans[0];
    return 0;
}

 
ZeroJudge Forum