Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <array>
- #include <vector>
- const int maxSize = 1000;
- std::array<int, maxSize> readInput(int& numberOfPipes) {
- std::array<int, maxSize> arr{};
- for (int i = 0; i < numberOfPipes; ++i) {
- std::cin >> arr[i];
- }
- return arr;
- }
- void checkLifeTime(std::array<int, maxSize>& checkUp, std::array<int, maxSize>& installation, int& numberOfPipes) {
- int lifetime = 0;
- for (int i = 0; i < numberOfPipes; ++i) {
- int damage = installation[i] - checkUp[i];
- while (installation[i] > 0) {
- if (damage > installation[i]) {
- break;
- }
- installation[i] -= damage;
- lifetime++;
- }
- std::cout << lifetime << ' ';
- lifetime = 0;
- }
- }
- int main() {
- int numberOfPipes;
- std::cin >> numberOfPipes;
- std::array<int, maxSize> checkUp = readInput(numberOfPipes);
- std::array<int, maxSize> installation = readInput(numberOfPipes);
- checkLifeTime(checkUp, installation, numberOfPipes);
- }
Advertisement
Add Comment
Please, Sign In to add comment