Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <fstream>
- using namespace std;
- int main ()
- {
- ifstream ins("p91.txt");
- ofstream ous("ans91.txt");
- int n,k;
- ins >> k >> n;
- vector <int> a;
- for (int i=0; i<n; i++)
- {
- int t;
- ins >> t;
- a.push_back(t);
- }
- int max_val=a[0];
- for (int i=1; i<n; i++)
- if (a[i]>max_val)
- max_val=a[i];
- for (int i=0; i<n; i++)
- if (a[i]==max_val)
- {
- a.insert(a.begin()+i+1, k);
- n=a.size();
- }
- for (int i=0; i<a.size(); i++)
- ous << a[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment