Pagini recente » Cod sursa (job #1911757) | Cod sursa (job #2389498) | Cod sursa (job #2646058) | Cod sursa (job #2087787) | Cod sursa (job #3166289)
#include <bits/stdc++.h>
#pragma optimize GCC ("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
///#include <tryhardmode>
///#include <GODMODE::ON>
using namespace std;
ifstream fin ("loto.in");
ofstream fout ("loto.out");
class InParser {
private:
FILE *fin;
char *buff;
int sp;
char read_ch() {
++sp;
if (sp == 4096) {
sp = 0;
fread(buff, 1, 4096, fin);
}
return buff[sp];
}
public:
InParser(const char* nume) {
fin = fopen(nume, "r");
buff = new char[4096]();
sp = 4095;
}
InParser& operator >> (int &n) {
char c;
while (!isdigit(c = read_ch()) && c != '-');
int sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
InParser& operator >> (long long &n) {
char c;
n = 0;
while (!isdigit(c = read_ch()) && c != '-');
long long sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
};
const int NMAX=1e2+5;
int v[NMAX];
struct elem{
int x;
int y;
int z;
};
map<int,elem>mp;
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(NULL);
fout.tie(NULL);
int n,s,i,j,k;
fin>>n>>s;
for(i=1;i<=n;i++)
fin>>v[i];
fin.close();
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
for(k=1;k<=n;k++)
mp[v[i]+v[j]+v[k]]={v[i],v[j],v[k]};
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
for(k=1;k<=n;k++)
{
if(mp.find(s-v[i]-v[j]-v[k])!=mp.end())
{
auto it=mp[s-v[i]-v[j]-v[k]];
fout<<v[i]<<" "<<v[j]<<" "<<v[k]<<" "<<it.x<<" "<<it.y<<" "<<it.z;
fout.close();
exit(0);
}
}
fout<<-1;
fout.close();
return 0;
}