题解
map |
---|
存在一个映射关系 |
差值 |
Code
#include <iostream>
#include <map>
using namespace std;
int main()
{
int N;
cin >> N;
map<int, int, greater<>> rap;
for (int i = 1; i <= N; i++)
{
int x;
cin >> x;
int y = abs(i - x);
rap[y]++;
}
for (auto &e : rap)
{
if (e.second >= 2)
cout << e.first << " " << e.second << endl;
}
return 0;
}