Cod sursa(job #3231450)

Utilizator Ruxandra009Ruxandra Vasilescu Ruxandra009 Data 26 mai 2024 15:53:30
Problema Oite Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <fstream>
#include <unordered_map>

using namespace std;

ifstream f("oite.in");
ofstream g("oite.out");

int n, s, maxi;
unordered_map< int, unordered_map<int, int> > a;

int main()
{
    f >> n >> s; a[0][0] = 1;
    for(int i = 1; i <= n; i ++)
    {
        int x; f >> x;
        for(int j = maxi; j >= 0; j --)
            for(int t = 0; t <= 3; t ++)
                if(a[j][t])
                    a[j + x][t + 1] += a[j][t];

        maxi = min(maxi + x, s);
    }

    g << a[s][4];
    return 0;
}