Seal_of_approval

P91

Nov 6th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <vector>
  2. #include <fstream>
  3. using namespace std;
  4. int main ()
  5. {
  6. ifstream ins("p91.txt");
  7. ofstream ous("ans91.txt");
  8. int n,k;
  9. ins >> k >> n;
  10. vector <int> a;
  11. for (int i=0; i<n; i++)
  12. {
  13. int t;
  14. ins >> t;
  15. a.push_back(t);
  16. }
  17. int max_val=a[0];
  18. for (int i=1; i<n; i++)
  19. if (a[i]>max_val)
  20. max_val=a[i];
  21. for (int i=0; i<n; i++)
  22. if (a[i]==max_val)
  23. {
  24. a.insert(a.begin()+i+1, k);
  25. n=a.size();
  26. }
  27. for (int i=0; i<a.size(); i++)
  28. ous << a[i] << " ";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment