Cant find an error in my code for Problem 2128 C

Revision en3, by joyz09, 2025-08-06 11:16:08
#include <iostream>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        long m = (long)INT_MAX;
        while(n--){
            long b;
            cin >> b;
            if(b <= m){
                m = b;
            }else{
                if(b > 2*m-1){
                    cout << "NO" << endl;
                    break;
                }
            }
            if(n==0) cout << "YES" << endl;
        }
    }
    return 0;
}

https://mirror.codeforces.com/problemset/problem/2128/C

It always shows wrong in test case 2 token 46 The test case is n = 3 1 2 2

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English joyz09 2025-08-06 11:16:08 2 Tiny change: '\n~~~~~\n#in' -> '~~~~~\n#in' (published)
en2 English joyz09 2025-08-06 11:15:08 129 (saved to drafts)
en1 English joyz09 2025-08-06 11:13:37 723 Initial revision (published)