Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<vector>
- #include<algorithm>
- using namespace std;
- int main()
- {
- int a,b;
- cin>>a>>b;
- int m[a][b];
- int razlika[a*b];
- int ri=0;
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<b;j++)
- {
- cin>>m[i][j];
- }
- }
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<b;j++)
- {
- int najmal=2e9;
- if(i-1>=0)
- {
- if(najmal>m[i-1][j])
- {
- najmal=m[i-1][j];
- }
- }
- if((i+1)<a)
- {
- if(najmal>m[i+1][j])
- {
- najmal=m[i+1][j];
- }
- }
- if(j-1>=0)
- {
- if(najmal>m[i][j-1])
- {
- najmal=m[i][j-1];
- }
- }
- if(j+1<b)
- {
- if(najmal>m[i][j+1])
- {
- najmal=m[i][j+1];
- }
- }
- if(najmal>m[i][j])
- {
- razlika[ri]=najmal-m[i][j];
- ri++;
- }
- }
- }
- sort(razlika,razlika+ri);
- for(int i=ri-1;i>=0;i--)
- {
- cout<<razlika[i]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement