Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int nums;
- while (cin >> nums) {
- int packets = 0;
- int last = 0;
- int bonus = 0;
- int rating;
- while (nums--) {
- cin >> rating;
- packets++;
- if (last && last != rating) {
- if (rating > last) {
- packets++;
- bonus = 1;
- }
- else {
- if (!bonus){
- packets++;
- bonus = 0;
- }
- }
- last = 0;
- }
- else {
- last = rating;
- }
- }
- cout << packets << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment