Advertisement
ekzolot

Untitled

Jan 30th, 2023
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main(){
  5.     int n;
  6.     cin>>n;
  7.     vector<int> t(n);
  8.     for (int i=0; i<n; i++){
  9.         cin>>t[i];
  10.         if (t[i]<0){
  11.             t[i]=(-1)*t[i];
  12.         }
  13.     }
  14.     int x=-1;
  15.     bool flag=true;
  16.     for (int i=0; i<n-1; i++){
  17.         if (t[i]>t[i+1]){
  18.             if (x==i-1){
  19.                 x=i;
  20.             }else{
  21.                 flag=false;
  22.             }
  23.         }
  24.         if (t[i]==t[i+1]){
  25.             if (x==i-1){
  26.                 x=i;
  27.             }
  28.         }
  29.     }
  30.     if (!flag){
  31.         cout<<"No"<<"\n";
  32.         return 0;
  33.     }
  34.     cout<<"Yes"<<"\n";
  35.     for (int i=0; i<n; i++){
  36.         if (i<=x){
  37.             cout<<-t[i]<<" ";
  38.         }else{
  39.             cout<<t[i]<<" ";
  40.         }
  41.     }
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement