41 lines
964 B
C++
41 lines
964 B
C++
|
/* PARTIEL TEMPS */
|
||
|
// Runtime error: doit-être relative au temps d'exécution,
|
||
|
// Je n'ai pas eu le temps d'optimiser plus
|
||
|
#include <iostream>
|
||
|
#include <vector>
|
||
|
#include <functional>
|
||
|
using namespace std;
|
||
|
|
||
|
|
||
|
int main() {
|
||
|
int n;
|
||
|
vector<pair<int, int>> discos;
|
||
|
int input1, input2;
|
||
|
|
||
|
cin >> n;
|
||
|
for (int i=0; i < n; i++) {
|
||
|
cin >> input1;
|
||
|
cin >> input2;
|
||
|
|
||
|
discos.push_back(pair<int, int>(input1, input2));
|
||
|
}
|
||
|
|
||
|
// On trie par ordre lexicographique sur (-x[0], x[1])
|
||
|
sort(
|
||
|
begin(discos),
|
||
|
end(discos),
|
||
|
[](pair<int, int> a, pair<int, int> b) {
|
||
|
return !(-a.second>-b.second || (a.second==b.second && a.first > b.first));
|
||
|
}
|
||
|
);
|
||
|
|
||
|
int discount = 1;
|
||
|
int balance = 0;
|
||
|
|
||
|
// On calcule le discount et les achats
|
||
|
for (int i=0; i < n; i++) {
|
||
|
balance -= discos[i].first / discount;
|
||
|
discount *= discos[i].second;
|
||
|
}
|
||
|
cout << (-balance) << "\n";
|
||
|
}
|