Cod sursa(job #2880693)

Utilizator radubuzas08Buzas Radu radubuzas08 Data 29 martie 2022 23:50:24
Problema Secventa 5 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream in("pariuri.in");
ofstream out("pariuri.out");

long long v[1000000];

bool exista[1000000];

int elemente_pe_linie, t_final, aux, x;

int main() {

    in >> aux;
    while (in >> elemente_pe_linie)
    {
        for (int i = 0; i < elemente_pe_linie; ++i) {
            in >> x;
            exista[x] = 1;
            if(t_final < x)
                t_final = x;
            in >> aux;
            v[x] += aux;
        }
    }

    out << t_final << '\n';
    for (int i = 1; i < 1000000; ++i) {
        if(exista[i])
            out << i << ' ' << v[i] << ' ';
    }
    
    in.close();
    out.close();

    return 0;
}