ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
#define ll long long
#define mp make_pair
#define yes cout << "YES" << "\n"
#define no cout << "NO" << "\n"

string decimalToBinary(ll decimal_number){
    bitset<64> binary(decimal_number);
    return binary.to_string();
}

ll binaryToDecimal(string &binary_string){
    bitset<64> binary(binary_string);
    return binary.to_ullong();
}

void solve() {
    ll l,r;
    cin>>l>>r;
    string a,b;
    a = decimalToBinary(l);
    b = decimalToBinary(r);
    ll x,y,z;
    for(ll i=0; i<a.size(); i++){
        if(a[i]!=b[i]) {
            x=i;
        }
    }
    for(ll i=x+1; i<a.size(); i++) b[i]='0';
    x = binaryToDecimal(b);
    y = x-1;
    z = x-2;
    if(z<l) z= x+1;
    cout<<x<<" "<<y<<" "<<z<<endl;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
#define ll long long
#define mp make_pair
#define yes cout << "YES" << "\n"
#define no cout << "NO" << "\n"

void solve() {
    ll l,r;
    cin>>l>>r;
    int k = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    std::cout << a << " " << b << " " << c << "\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
//
// Created by Jiwon Sheen on 2025-02-02
//
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

inline void fastIo() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

using pii = pair<int, int>;

int main() {
    int t;
    int n;
    int ans;
    vector<vector<int>> v;
    vector<int> de;
    vector<bool> chk;
    priority_queue<pii> pq;

    fastIo();

    cin >> t;

    while (t--) {
        cin >> n;

        ans = 1;
        v.assign(n + 1, vector<int>());
        de.assign(n + 1, 0);
        chk.assign(n + 1, false);

        for (int i = 0; i < n - 1; i++) {
            int a, b;
            cin >> a >> b;
            de[a]++, de[b]++;
            v[a].push_back(b);
            v[b].push_back(a);
        }


        for (int i = 1; i <= n; i++)
            pq.emplace(de[i], i);

        for (int k = 0; k < 2; k++) {
            while (pq.top().first != de[pq.top().second])
                pq.pop();
            auto [cd, idx] = pq.top();
            pq.pop();
            chk[idx] = true;

            ans += cd - 1;
            for (const auto &nxt: v[idx]) {
                if (!chk[nxt])
                    pq.emplace(--de[nxt], nxt);
            }
        }

        while (!pq.empty())
            pq.pop();

        if (n >= 3) {
            int ans2 = 1;

            for (int i = 1; i <= n; i++)
                pq.emplace(de[i], i);

            chk.assign(n + 1, false);
            chk[pq.top().second] = true;
            pq.pop();

            for (int k = 0; k < 2; k++) {
                while (pq.top().first != de[pq.top().second])
                    pq.pop();
                auto [cd, idx] = pq.top();
                pq.pop();
                chk[idx] = true;

                ans2 += cd - 1;
                for (const auto &nxt: v[idx]) {
                    if (!chk[nxt])
                        pq.emplace(--de[nxt], nxt);
                }
            }
            ans = max(ans, ans2);
        }

        cout << ans << '\n';
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 1):
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define INT __int128
#define N 100010

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned int;

int lowbit(int t)
{
	return t * -t;
}

void sol()
{
	int l, r;
	cin >> l >> r;
	int t = l ^ r;
	while(t != lowbit(t))
		t -= lowbit(t);
	t |= l;
	int a, b, c;
	a = t, b = t - 1, c = r;
	while(c == a || c == b)	c --;
	cout << a << ' ' << b << ' ' << c << endl;
}

int main() 
{
	IOS;
	int t = 1;
	cin >> t;
	while(t--)
		sol();
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 1):
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define INT __int128
#define N 100010

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned int;

int lowbit(int t)
{
	return t * -t;
}

void sol()
{
	int l, r;
	cin >> l >> r;
	int t = l ^ r;
	while(t != lowbit(t))
		t -= lowbit(t);
	t |= l;
	int a, b, c;
	a = t, b = t - 1, c = r;
	while(c == a || c == b)	c --;
	cout << a << ' ' << b << ' ' << c << endl;
}

int main() 
{
	IOS;
	int t = 1;
	cin >> t;
	while(t--)
		sol();
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define endl '\n'
#define INT __int128
#define N 100010

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned int;

int lowbit(int t)
{
	return t & -t;
}

void sol()
{
	int l, r;
	cin >> l >> r;
	int t = l ^ r;
//	cout << lowbit(t) << endl;
	while(t != lowbit(t))
		t -= lowbit(t);
//	cout << t << endl;
	t |= l;
//	cout << t << endl;
	int a, b, c;
	a = t, b = t - 1, c = r;
	while(c == a || c == b)	c --;
	cout << a << ' ' << b << ' ' << c << endl;
}

int main() 
{
	IOS;
	int t = 1;
	cin >> t;
	while(t--)
		sol();
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define endl '\n'
#define INT __int128
#define N 100010

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned int;

int lowbit(int t)
{
	return t & -t;
}

void sol()
{
	int l, r;
	cin >> l >> r;
	int t = l ^ r;
//	cout << lowbit(t) << endl;
	while(t != lowbit(t))
		t -= lowbit(t);
//	cout << t << endl;
	t |= l;
//	cout << t << endl;
	int a, b, c;
	a = t, b = t - 1, c = r;
	while(c == a || c == b)	c --;
	cout << a << ' ' << b << ' ' << c << endl;
}

int main() 
{
	IOS;
	int t = 1;
	cin >> t;
	while(t--)
		sol();
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define endl '\n'
#define INT __int128
#define N 100010

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned int;

int lowbit(int t)
{
	return t & -t;
}

void sol()
{
	int l, r;
	cin >> l >> r;
	int t = l ^ r;
//	cout << t << endl;
	while(t != lowbit(t))
		t -= lowbit(t);
//	cout << t << endl;
	t = (l / t * t) | t;
//	cout << t << endl;
	int a, b, c;
	a = t, b = t - 1, c = r;
	while(c == a || c == b)	c --;
	cout << a << ' ' << b << ' ' << c << endl;
}

int main() 
{
	IOS;
	int t = 1;
	cin >> t;
	while(t--)
		sol();
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int,int>mp;
int tot[200005];
int n,m,idt,x;
void solve(){
	idt=0;
	mp.clear();
	for(int i=1;i<=n;i++){
		tot[i]=0;
	}
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		if(mp[x]==0){
			mp[x]=++idt;
		}
		x=mp[x];
		tot[x]++;
	}
	int ans=idt;
	sort(tot+1,tot+idt+1);
	for(int i=1;i<idt;i++){
		if(m<=0)break;
		if(tot[i]<=m){
			m-=tot[i];
		}
		ans--;
	}
	printf("%lld\n",ans);
}
signed main(){
#ifdef USE_FILE_IO
	freopen("code.in","r",stdin);
	freopen("code.out","w",stdout);
#endif
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int,int>mp;
vector<int>num;
int n,m,idt,x;
void solve(){
	idt=0;
	mp.clear();
	num.clear();
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		mp[x]++;
	}
	for(auto _:mp){
		num.push_back(_.second);
	}
	sort(num.begin(),num.end());
	int ans=num.size();
	for(auto i:num){
		if(m<=0)break;
		if(i<=m){
			m-=i;
		}
		ans--;
	}
	printf("%lld\n",max(ans,1ll));
}
signed main(){
#ifdef USE_FILE_IO
	freopen("code.in","r",stdin);
	freopen("code.out","w",stdout);
#endif
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int,int>mp;
vector<int>num;
int n,m,idt,x;
void solve(){
	idt=0;
	mp.clear();
	num.clear();
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		mp[x]++;
	}
	for(auto _:mp){
		num.push_back(_.second);
	}
	sort(num.begin(),num.end());
	int ans=num.size();
	for(auto i:num){
		if(m<=0)break;
		if(i<=m){
			m-=i;
		}
		ans--;
	}
	printf("%lld\n",max(ans,1ll));
}
signed main(){
#ifdef USE_FILE_IO
	freopen("code.in","r",stdin);
	freopen("code.out","w",stdout);
#endif
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Submission (verdict: Time limit exceeded on test 14):
#include<bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int,int>mp;
vector<int>num;
int n,m,idt,x;
void solve(){
	mp.clear();
	num.clear();
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		mp[x]++;
	}
	for(auto _:mp){
		num.push_back(_.second);
	}
	sort(num.begin(),num.end());
	// int ans=num.size();
	// for(auto i:num){
	// 	if(m<=0)break;
	// 	if(i<=m){	
	// 		m-=i;
	// 	}
	// 	ans--;
	// }
	// printf("%lld\n",max(ans,1ll));
	bool flag=false;
	for(int i=0;i<num.size();i++){
		if(m>=num[i])
			m-=num[i];
		else{
			printf("%lld\n",num.size()-i);
			flag=true;
			break;
		}
	}
	if(!flag){
		printf("1\n");
	}
}
signed main(){
#ifdef USE_FILE_IO
	freopen("code.in","r",stdin);
	freopen("code.out","w",stdout);
#endif
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int,int>mp;
int tot[200005];
int n,m,idt,x;
void solve(){
	idt=0;
	mp.clear();
	for(int i=1;i<=n;i++){
		tot[i]=0;
	}
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		if(mp[x]==0){
			mp[x]=++idt;
		}
		x=mp[x];
		tot[x]++;
	}
	int ans=idt;
	sort(tot+1,tot+idt+1);
	for(int i=1;i<idt;i++){
		if(m<=0)break;
		if(tot[i]<=m){
			m-=tot[i];
		}
		ans--;
	}
	printf("%lld\n",ans);
}
signed main(){
#ifdef USE_FILE_IO
	freopen("code.in","r",stdin);
	freopen("code.out","w",stdout);
#endif
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include<bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int,int>mp;
vector<int>num;
int n,m,idt,x;
void solve(){
	mp.clear();
	num.clear();
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		mp[x]++;
	}
	for(auto _:mp){
		num.push_back(_.second);
	}
	sort(num.begin(),num.end());
	// int ans=num.size();
	// for(auto i:num){
	// 	if(m<=0)break;
	// 	if(i<=m){	
	// 		m-=i;
	// 	}
	// 	ans--;
	// }
	// printf("%lld\n",max(ans,1ll));
	bool flag=false;
	for(int i=0;i<num.size();i++){
		if(m>=num[i])
			m-=num[i];
		else{
			printf("%lld\n",num.size()-i);
			flag=true;
			break;
		}
	}
	if(!flag){
		printf("1\n");
	}
}
signed main(){
#ifdef USE_FILE_IO
	freopen("code.in","r",stdin);
	freopen("code.out","w",stdout);
#endif
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
using namespace std;
map<int,int>mp;
vector<int>num;
int n,m,idt,x;
void solve(){
	mp.clear();
	num.clear();
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		mp[x]++;
	}
	for(auto _:mp){
		num.push_back(_.second);
	}
	sort(num.begin(),num.end());
	bool flag=false;
	int s=num.size();
	for(int i=0;i<s;i++){
		if(m>=num[i]){
			m-=num[i];
		}
		else{
			printf("%lld\n",s-i);
			flag=true;
			return;
		}
	}
	printf("1\n");
}
signed main(){
#ifdef USE_FILE_IO
	freopen("code.in","r",stdin);
	freopen("code.out","w",stdout);
#endif
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(int i=0;i<n-1;i+=2){
        int temp=arr[i+1] - arr[i];
        if(arr[i]<=arr[i+1] && i+2<n && arr[i+2]>=temp){
            ans=true;
        }
        else if(arr[i]>arr[i+1]){
            ans=false;
            break;
        }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }



    }

    
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(int i=0;i<n-1;i++){
       if(i-2>=0 && arr[i]-(arr[i-1]-min(arr[i-1],arr[i-2]))<=arr[i+1]){
         ans = true;
       }
       else{
        ans = false;
       }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }
      



    }

    
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(int i=0;i<n-1;i+=2){
        int temp=arr[i+1] - arr[i];
        if(arr[i]<=arr[i+1] && arr[i+2]>=temp && i+2<n){
            ans=true;
        }
        else if(arr[i]>arr[i+1]){
            ans=false;
            break;
        }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }



    }

    
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(int i=0;i<n-1;i++){
       if(i-2>=0 && arr[i]-(arr[i-1]-min(arr[i-1],arr[i-2]))<=arr[i+1]){
         ans = true;
       }
       else{
        ans = false;
       }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }
      



    }

    
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(int i=0;i<n-1;i++){
       if(i-2>=0 && arr[i]-(arr[i-1]-min(arr[i-1],arr[i-2]))<=arr[i+1]){
         ans = true;
       }
       else if(arr[i]<arr[i+1]){
        ans = true;
       }
       else{
        ans=false;
       }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }
      



    }

    
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(int i=0;i<n-1;i+=2){
        int temp=arr[i+1] - arr[i];
        if(arr[i]<=arr[i+1] && arr[i+2]>=temp && i+2<n){
            ans=true;
        }
        else if(arr[i]>arr[i+1]){
            ans=false;
            break;
        }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }



    }

    
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(int i=0;i<n-1;i+=2){
        int temp=arr[i+1] - arr[i];
        if(arr[i]<=arr[i+1] && i+2<n && arr[i+2]>=temp){
            ans=true;
        }
        else if(arr[i]>arr[i+1]){
            ans=false;
            break;
        }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }



    }

    
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(int i=0;i<n-1;i++){
       if(i-2>=0 && arr[i]-(arr[i-1]-min(arr[i-1],arr[i-2]))<=arr[i+1]){
         ans = true;
       }
       else if(arr[i]<arr[i+1]){
        ans = true;
       }
       else{
        ans=false;
       }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }
      



    }

    
}

Submission (verdict: Accepted):
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
      ll n;
      cin>>n;  
      vector<int> arr(n);
      for(ll i=0;i<n;i++){
        cin>>arr[i];
      }
      bool ans=true;
      for(ll i=0;i<n-1;i++){
        int temp=arr[i];
        arr[i]=arr[i]-min(arr[i],arr[i+1]);
        arr[i+1]=arr[i+1]-min(temp,arr[i+1]);
        if(arr[i]>arr[i+1]){
            ans=false;
            break;
        }
      }
      if(ans){
        cout<<"YES"<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }
    }

    
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>



using namespace std;



const int N = 200010;



int t,n;

int a[N];



int main()

{

cin >> t;

while(t -- )

{

int res = 0;

cin >> n;



for(int i = 1;i <= n;i ++ )

{

cin >> a[i];

}

bool flag = true;

for(int i = 1;i < n;i ++ )

{

if(a[i] > a[i + 1])

{

if((a[i] - min(a[i],a[i - 1])) > a[i + 1])

{

flag = false;

break;

}else

{

a[i] -= min(a[i],a[i - 1]);

a[i - 1] -= min(a[i],a[i - 1]);

}

}

}



if(!flag)puts("NO");

else puts("YES");



}

return 0;

}





Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

#define int long long



const int N = 200005;

int a[N];



signed main(){

ios::sync_with_stdio(false);

cin.tie(0) , cout.tie(0);

int t;

cin >> t;

while(t --){

int n;

cin >> n;

for(int i = 1 ; i <= n ; i ++)

cin >> a[i];

bool ok = 0;

for(int i = 1 ; i < n ; i ++){

if(a[i] <= a[i - 1] + a[i + 1]){

int x = min(a[i] , a[i - 1]);

a[i - 1] -= x;

a[i] -= x;

}else{

ok = 1;

break;

}

}

if(ok)

cout << "NO" << '\n';

else

cout << "YES" << '\n';

for(int i = 1 ; i <= n ; i ++)

a[i] = 0;

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>



using namespace std;



const int N = 200010;



int t,n;

int a[N];



int main()

{

cin >> t;

while(t -- )

{

int res = 0;

cin >> n;

for(int i = 1;i <= n;i ++ )

{

cin >> a[i];

res = max(res,a[i]);

}

if(a[1] == res)cout << "NO" << endl;

else cout << "YES" << endl;

}

return 0;

}





Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>



using namespace std;



const int N = 200010;



int t,n;

int a[N];



int main()

{

cin >> t;

while(t -- )

{

int res = 0;

cin >> n;



for(int i = 1;i <= n;i ++ )

{

cin >> a[i];

}

bool flag = true;

for(int i = 2;i < n;i ++ )

{

if(a[i] > a[i + 1])

{

if((a[i] - min(a[i],a[i - 1])) > a[i + 1])

{

flag = false;

break;

}else

{

a[i] -= min(a[i],a[i - 1]);

a[i - 1] -= min(a[i],a[i - 1]);

}

}

}

if(!flag)puts("NO");

else puts("YES");



}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>



using namespace std;



const int N = 200010;



int t,n;

int a[N];



int main()

{

cin >> t;

while(t -- )

{

int res = 0;

cin >> n;



for(int i = 1;i <= n;i ++ )

{

cin >> a[i];

}

bool flag = true;

for(int i = 2;i < n;i ++ )

{

if(a[i] > a[i + 1])

{

if((a[i] - min(a[i],a[i - 1])) > a[i + 1])

{

flag = false;

break;

}else

{

a[i] -= min(a[i],a[i - 1]);

a[i - 1] -= min(a[i],a[i - 1]);

}

}

}

if(!flag)puts("NO");

else puts("YES");



}

return 0;

}





Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>



using namespace std;



const int N = 200010;



int t,n;

int a[N];



int main()

{

cin >> t;

while(t -- )

{

int res = 0;

cin >> n;



for(int i = 1;i <= n;i ++ )

{

cin >> a[i];

}

bool flag = true;

for(int i = 1;i < n;i ++ )

{

if(a[i] > a[i + 1])

{

if((a[i] - min(a[i],a[i - 1])) > a[i + 1])

{

flag = false;

break;

}else

{

a[i] -= min(a[i],a[i - 1]);

a[i - 1] -= min(a[i],a[i - 1]);

}

}

}



if(!flag)puts("NO");

else puts("YES");



}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>



using namespace std;



const int N = 200010;



int t,n;

int a[N];



int main()

{

cin >> t;

while(t -- )

{

int res = 0;

cin >> n;

for(int i = 1;i <= n;i ++ )

{

cin >> a[i];

res = max(res,a[i]);

}

if(a[1] == res)cout << "NO" << endl;

else cout << "YES" << endl;

}

return 0;

}