Cod sursa(job #1469375)

Utilizator tamionvTamio Vesa Nakajima tamionv Data 8 august 2015 07:50:11
Problema Oite Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <fstream>
#include <vector>
#include <unordered_set>
using namespace std;

int main(){
	ifstream f("oite.in");
	ofstream g("oite.out");
	int n;
	long long l;
	f >> n >> l;
	vector<long long> v(n);
	for(auto& x : v){
		f >> x; }
	long long rez = 0;
	unordered_multiset<long long> s;
	for(int third = 2; third+1 < n; ++third){
		for(int first = 0; first+1 < third; ++first){
			s.insert(v[first] + v[third-1]); }
		for(int fourth = third+1; fourth < n; ++fourth){
			rez += s.count(l - v[third] - v[fourth]); } }
	g << rez;
	return 0; }