Cod sursa(job #881087)

Utilizator Theorytheo .c Theory Data 17 februarie 2013 18:19:59
Problema Lupul Urias si Rau Scor 8
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include<fstream>
#include<vector>

using namespace std;
ifstream fin("lupu.in");
ofstream fout("lupu.out");

const int Nmax = 100009;

int N; int X; int L;

vector<int> V[Nmax];

void Read() {

    fin >>N >> X >> L;
    for(int i = 1; i <= N; ++i){
        int x, y; fin >>x >> y;
        V[(X - x) / L + 1].push_back(y);
    }
}

void Solve(){

    int MaxL , MaxS = 0;
    for(int i = 1; i < Nmax; ++i){
        MaxL = 0;
        for(int j = 0 ;j < V[i].size(); ++j){
            if(V[i][j] > MaxL)
             MaxL = V[i][j];
        }
        MaxS += MaxL;
    }
    fout << MaxS <<'\n';
}

int main(){

    Read ();

    Solve ();
    return 0;
}