Cod sursa(job #2797452)
| Utilizator | Data | 9 noiembrie 2021 21:59:44 | |
|---|---|---|---|
| Problema | Oite | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("oite.in");
ofstream fout("oite.out");
int n, L, a[1100], cnt;
unordered_map<int, int>M;
int main()
{
fin >> n >> L;
for(int i = 1; i <= n; i++)
fin >> a[i];
sort(a+1, a+n+1);
/// 1 1 1 8 9 10 10 12 12 13
for(int i = 1; i <= n; i++)
{
for(int j = i + 1; j <= n; j++)
{
int x = a[i] + a[j];
if(M.find(L - x) != M.end())
cnt+=M[L - x];
}
for(int j = 1; j < i; j++)
M[a[i]+a[j]]++;
}
fout << cnt;
return 0;
}
