yordanganev

pc2017B-WA

May 5th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int nums;
  7.     while (cin >> nums) {
  8.         int packets = 0;
  9.         int last = 0;
  10.         int bonus = 0;
  11.         int rating;
  12.         while (nums--) {
  13.             cin >> rating;
  14.             packets++;
  15.            
  16.             if (last && last != rating) {
  17.                 if (rating > last) {
  18.                     packets++;
  19.                     bonus = 1;
  20.                 }
  21.                 else {
  22.                     if (!bonus){
  23.                         packets++;
  24.                         bonus = 0;
  25.                     }
  26.                 }
  27.                 last = 0;
  28.             }
  29.             else {
  30.                 last = rating;
  31.             }
  32.  
  33.         }
  34.         cout << packets << endl;
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment