fork download
  1. /*
  2.   Cred : SunnyYeahBoi
  3.   It's my last chance (⌐■_■)
  4.   Problem :
  5. */
  6.  
  7. #include<bits/stdc++.h>
  8.  
  9. using namespace std;
  10.  
  11. #define int long long
  12. #define double long double
  13. #define endl "\n"
  14. #define NAME "a"
  15.  
  16. const int MAXN = 1e5 + 5;
  17. const int inf = 1e18;
  18. const int MOD = 1e9 + 7;
  19. const int shift = 2e5;
  20.  
  21. void FileInput(){
  22. if(fopen(NAME".inp" , "r") == NULL)
  23. freopen(NAME".inp" , "w" , stdout);
  24. freopen(NAME".inp" , "r" , stdin);
  25. freopen(NAME".out" , "w" , stdout);
  26. }
  27.  
  28. int n , k;
  29. int a[MAXN];
  30. int cnt[2 * shift + 15];
  31.  
  32. void solve(){
  33. cin >> n;
  34. for(int i = 1 ; i <= n ; i++)
  35. cin >> a[i];
  36.  
  37. int res = 0;
  38. for(int i = 1 ; i <= n ; i++){
  39. res += cnt[a[i] - i + shift];
  40. cnt[a[i] - i + shift]++;
  41. }
  42.  
  43. cout << res << endl;
  44. }
  45.  
  46. int32_t main(){
  47. FileInput();
  48. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  49. int t = 1;
  50. // cin >> t;
  51. while(t--)
  52. solve();
  53. return 0;
  54. }
  55.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty