Submission #68126409


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vec vector
#define fir first
#define sec second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
const int mod = 998244353;
const int N = 200005;
const int inf = 0x3f3f3f3f3f3f3f3f;
int a[N],cnt[900005];
void Thirstarfish()
{
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cnt[i-a[i]+400005]++;
    for(int i=1;i<=n;i++)
        ans+=cnt[a[i]+i+400005];
    cout<<ans<<endl;
}

signed main()
{
        ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    // cin >> _;  //如果是单测记得注释掉这一行
    while (_--)
        Thirstarfish();
    return 0;
}

/*
 things to check
 1.  int overflow or long long memory need
 2.  recursion/array/binary search/dp/loop bounds
 3.  precision
 4.  special cases(n=1,bounds)
 5.  delete debug statements
 6.  initialize(especially multi-tests)
 7.  = or == , n or m ,++ or -- , i or j , > or >= , < or <=
 8.  keep it simple and stupid
 9.  do not delete, use // instead
 10. operator priority
 11. is there anything extra to output?
 12. ...


  something to think about
  1. greedy? dp? searching? dp with matrix/ segment tree? binary search?
  2. If contains "not", why not ?????? or few affect?

  */

Submission Info

Submission Time
Task C - Distance Indicators
User Thirstarfish
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1449 Byte
Status AC
Exec Time 13 ms
Memory 8312 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3424 KiB
00_sample_01.txt AC 1 ms 3632 KiB
00_sample_02.txt AC 1 ms 3504 KiB
01_random_03.txt AC 8 ms 6820 KiB
01_random_04.txt AC 10 ms 7220 KiB
01_random_05.txt AC 6 ms 6376 KiB
01_random_06.txt AC 10 ms 7464 KiB
01_random_07.txt AC 13 ms 8104 KiB
01_random_08.txt AC 13 ms 8188 KiB
01_random_09.txt AC 13 ms 8312 KiB
01_random_10.txt AC 13 ms 8180 KiB
01_random_11.txt AC 9 ms 5820 KiB
01_random_12.txt AC 3 ms 4396 KiB
01_random_13.txt AC 8 ms 6428 KiB
01_random_14.txt AC 3 ms 4052 KiB
01_random_15.txt AC 10 ms 6624 KiB
01_random_16.txt AC 10 ms 7284 KiB
01_random_17.txt AC 6 ms 5928 KiB
01_random_18.txt AC 2 ms 3656 KiB
01_random_19.txt AC 8 ms 6544 KiB
01_random_20.txt AC 12 ms 8136 KiB
01_random_21.txt AC 12 ms 8072 KiB
01_random_22.txt AC 12 ms 8168 KiB
01_random_23.txt AC 12 ms 8244 KiB
01_random_24.txt AC 9 ms 6104 KiB
01_random_25.txt AC 10 ms 6764 KiB
01_random_26.txt AC 10 ms 6636 KiB
01_random_27.txt AC 9 ms 6764 KiB
01_random_28.txt AC 10 ms 6612 KiB