Advertisement
Zeinab_Hamdy

Untitled

Mar 30th, 2023
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define ull unsigned ll
  5. #define nl "\n"
  6. #define sz(x) int(x.size())
  7. #define NumOfDigit(w) log10(w) + 1
  8. #define fill(arr, val)  memset(arr, val , sizeof(arr))
  9. #define PI 3.141592654
  10. #define ceil(w, m) (((w) / (m)) + ((w) % (m) ? 1 : 0))
  11. #define all(v) v.begin(), v.end()
  12. #define rall(v) v.rbegin(), v.rend()
  13. #define fi first
  14. #define se second
  15. #define cin(v) for (auto&i:v) cin >> i;
  16. #define cout(v) for (auto&i:v) cout << i << " ";
  17. #define fixed(n) fixed << setprecision(n)
  18. //#define MOD  1e9 + 7
  19.  
  20.  
  21. void IO(){
  22.     ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  23. }
  24. void files(){
  25.     //freopen("filename.in" , "r" ,stdin);
  26.             #ifndef ONLINE_JUDGE
  27.               freopen("input.txt", "r", stdin);  freopen("output.txt", "w", stdout);
  28.             #endif
  29. }
  30.  
  31.  
  32. void solve(){
  33.  
  34.  
  35. ll n  ;
  36. cin >> n ;
  37.  
  38. n <<=1;
  39.  
  40.  
  41. ll x ,start=-1  , end =-1 , cnt=0;
  42.  
  43. for(ll i=1;i<=n;i++){
  44.    
  45.    
  46.     cin >> x;
  47.    
  48.    
  49.    if( start == -1 ){ // i=1
  50.        start = x;
  51.        end = x+ x/3 ;
  52.       // cout << x << " ";
  53.    }
  54.    
  55.    
  56.    
  57.     if( x < end ) {
  58.        cout << x << " ";
  59.    }
  60.    else if( x > end ) {
  61.        cout << x << " ";
  62.        start = x , end = x + x/3;
  63.        cnt=0;
  64.    }
  65.    
  66. }
  67.  
  68.  
  69. }
  70.  
  71. int main(){
  72.              //    IO();       //  files();
  73.  
  74. cin.tie(0);
  75. cout.tie(0);
  76. ios::sync_with_stdio(0);
  77.  
  78.     int testCase=1;  // one test case
  79.   //  cin >> testCase ;      
  80.  while(testCase--)
  81.         solve();  // my code
  82.        
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement