1 solutions

  • 0
    @ 2023-1-17 22:28:41
    #include <bits/stdc++.h>
    using namespace std;
    int a[1000];
    int main()
    {
    	int n,m,h=0;
    	cin>>n>>m;
    	for(int i=0;i<m;i++)
    	{
    		cin>>a[i];
    	}
    	for(int i=0;i<m;i++)
    	{
    		if(a[i+1]>n)
    		{
    			cout<<a[i]<<" ";
    			cout<<n<<" ";
    			break;
    		}
    		cout<<a[i]<<" ";
    		h++;
    	}
    	for(int i=h+1;i<m;i++)
    	{
    		cout<<a[i]<<" ";
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    501
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    10
    Tags
    # Submissions
    6
    Accepted
    6
    Uploaded By