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];
- vector<int> dlapki;
- 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 < a) {
- najmal = min(najmal, m[i + 1][j]);
- }
- if(i - 1 >= 0) {
- najmal = min(najmal, m[i - 1][j]);
- }
- if(j + 1 < b) {
- najmal = min(najmal, m[i][j + 1]);
- }
- if(j - 1 >= 0) {
- najmal = min(najmal, m[i][j - 1]);
- }
- if(najmal > m[i][j]) {
- dlapki.push_back(najmal - m[i][j]);
- }
- }
- }
- sort(dlapki.rbegin(), dlapki.rend());
- for(int i = 0; i < dlapki.size(); i++) {
- cout << dlapki[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement