Exact same solution, one rejected, other is not

My solution to the problem below is the same as the one in USACO guide but somehow my solution is rejected??? Says I got the wrong answer on test #8, how is this possible?
Solution - William and Robot (CF) · USACO Guide

#include <bits/stdc++.h>
using namespace std;

int main(){
    size_t N; cin >> N;
    vector<ssize_t> a(N);
    multiset<ssize_t> W;
    for (size_t i=0; i<N; ++i){
        cin >> a[i];
    }
    W.insert(max(a[0], a[1]));
    for (size_t i=2; i<N; i+=2){
        if (*W.begin() < min(a[i],a[i+1])){
            W.erase(W.begin());
            W.insert(a[i]);
            W.insert(a[i+1]);
        }
        else{
            W.insert(max(a[i], a[i+1]));
        } 
    }
    ssize_t ans = 0;
    for (ssize_t w: W){
        ans += w;
    }
    cout << ans << endl;
}
1 Like

ssize_t and long long are not always interchangeable. Try comparing sizeof(ssize_t) and sizeof(long long) in custom test.

Depends on which version of C++ you submit with. In particular, it will pass if you submit using C++20 64-bit.

1 Like