Cod sursa(job #3276979)

Utilizator crina2120Arnautu Cristina-Crina crina2120 Data 15 februarie 2025 10:58:15
Problema Numarare Scor 50
Compilator cpp-64 Status done
Runda vs11_12_vine_oji_2025 Marime 0.47 kb
#include <bits/stdc++.h>
using namespace std;

ifstream fin("numarare.in");
ofstream fout("numarare.out");

int n, a[100003];
unsigned long long s, cnt;

int main()
{
	int i, x, y;
	fin >> n;
	for (i = 1; i <= n; i++)
		fin >> a[i];
	for (i = 1; i < n; i++)
	{
		x = i;
		y = i + 1;
		s = a[x] + a[y];
		while (x >= 1 && y <= n && a[x] + a[y] == s)
		{
			x--;
			y++;
		}
		x++;
		y--;
		cnt += (y - x + 1) / 2;
	}
	fout << cnt << "\n";
	return 0;
}