MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Codeforces_problems/Lineland Mail/solution.cpp:7–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5 The minimum value will be difference between adjacent costs */
6using namespace std;
7int main(){
8 int n;
9 vector<long> cood;//Vector to take input of coordinates
10 cin>>n;
11 for(int i=0;i<n;i++){
12 long num;
13 cin>>num;
14 cood.push_back(num);
15 }
16 for(int i=0;i<n;i++){
17 if(i==0){
18 cout<<cood[i+1]-cood[i]<<" "<<cood[n-1]-cood[i]<<endl;
19 }
20 else if(i==n-1){
21 cout<<cood[i]-cood[i-1]<<" "<<cood[i]-cood[0]<<endl;
22 }
23 else if(i>=1 || i<n-1)
24 {
25 cout<<min((cood[i+1]-cood[i]),(cood[i]-cood[i-1]))<<" "<<max((cood[n-1]-cood[i]),(cood[i]-cood[0]))<<endl;//max and min cost for mail delivery
26 }
27 }
28 return 0;
29}

Callers

nothing calls this directly

Calls 2

minFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected