Pagini recente » Cod sursa (job #2255682) | Cod sursa (job #1696859) | Cod sursa (job #1829913) | Cod sursa (job #3225041) | Cod sursa (job #1469376)
#include <fstream>
#include <vector>
#include <unordered_map>
using namespace std;
class my_multiset{
unordered_map<long long, int> m;
public:
void insert(const long long x){
auto it = m.find(x);
if(it == end(m)){
m.emplace(x, 1); }
else{
++(it->second); } }
int count(const long long x){
auto it = m.find(x);
return (it == end(m)) ? 0 : it->second; } };
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;
my_multiset 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; }