Cod sursa(job #3276976)
| Utilizator | Data | 15 februarie 2025 10:57:12 | |
|---|---|---|---|
| Problema | Numarare | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | vs11_12_vine_oji_2025 | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("numarare.in");
ofstream fout("numarare.out");
int n, a[100003], cnt, s;
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;
}
