标签:bsp out 存在 题目 class ble end iostream str
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805260780945408
题解:
1 #include <iostream> 2 using namespace std; 3 const int MAXN = 10000 + 5; 4 5 int main() { 6 int n; 7 cin >> n; 8 int *p = new int[n]; 9 for (int i = 0; i < n; i++) { 10 cin >> p[i]; 11 } 12 int ans[MAXN] = { 0 }; 13 for (int i = 0; i < n; i++) { 14 int temp = p[i] - i - 1; 15 if (temp < 0) temp = -temp; 16 ans[temp]++; 17 } 18 for (int i = MAXN - 1; i >= 0; i--) //从大到小输出 19 if (ans[i] > 1) cout << i << " " << ans[i] << endl; 20 return 0; 21 }
标签:bsp out 存在 题目 class ble end iostream str
原文地址:https://www.cnblogs.com/Gzu_zb/p/9595207.html