Advertisement
for-mile

task491

Dec 9th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <fstream>
  5. using namespace std;
  6. #define vi vector<int>
  7.  
  8. int get_last_max(int idx, const vi& data)
  9. {
  10.     int res = data[idx];
  11.     for(int k = idx; k < data.size(); ++k)
  12.     {
  13.         res = max(data[k], res);
  14.     }
  15.     return res;
  16. }
  17.  
  18. int main()
  19. {
  20.     vi va;
  21.     int a;
  22.     ifstream in("input.txt");
  23.     ofstream out("output.txt");
  24.     int pos = 0;
  25.     while(in >> a)
  26.     {
  27.         va.push_back(a);
  28.         if(va.size() % 100 == 0)
  29.         {
  30.             out << get_last_max(pos, va) << " ";
  31.             pos += 100;
  32.         }
  33.     }
  34.     if(va.size() % 100 != 0)
  35.         out << get_last_max(pos, va);
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement