Cod sursa(job #1956691)

Utilizator iordache.bogdanIordache Ioan-Bogdan iordache.bogdan Data 6 aprilie 2017 23:01:14
Problema Stergeri Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>

int main() {
	std::ifstream inputFile("stergeri.in");
	std::ofstream outputFile("stergeri.out");

	int N, M, K;
	inputFile >> N >> M >> K;

	std::vector< std::pair<int, int> > op(M);
	for (auto& it : op)
		inputFile >> it.first >> it.second;

	std::reverse(op.begin(), op.end());

	for (auto& it : op) {
		if (it.first <= K)
			K += it.second - it.first + 1;
	}

	outputFile << K << '\n';

	inputFile.close();
	outputFile.close();

	return 0;
}

//Trust me, I'm the Doctor!