/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 344.0 KiB
#2 Wrong Answer 14ms 580.0 KiB
#3 Wrong Answer 8ms 568.0 KiB
#4 Wrong Answer 9ms 656.0 KiB
#5 Wrong Answer 22ms 1.246 MiB
#6 Wrong Answer 22ms 1.176 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
void solve()
{
   ll RoyFirst = 0, RoySecond = 0 , HridoyFirst = 0 , HridoySecond = 0  ,  a , n; cin >> n ;
   vector < int > odd , even ;
   for(int i = 0 ; i < n ; i++){
    cin >> a ;
    a & 1 ? odd.pb(1) : even.pb(1) ;
   }
   sort_d(odd) ;
   sort_d(even) ;
   int i = 0 , j = 1 , ok = -1;
   // First Option to choose number
   while(1){
    if(ok == -1){
        if(i < even.size()){
            RoyFirst += even[i] ;
            if(i + 1 < even.size()) HridoyFirst += even[i + 1] ;
            i += 2 ;
            ok = 1 ;
        }
        else break ;
    }
    else if(ok == 1){
        if(j < odd.size()){
            RoyFirst += odd[j] ;
            if(j + 1 < odd.size()) HridoyFirst += odd[j + 1] ;
            j += 2 ;
            ok = 0 ;
        }
        else break ;
    }
    else {
        if(i < even.size()){
            RoyFirst += even[i] ;
            if(i + 1 < even.size()) HridoyFirst += even[i + 1] ;
            i += 2 ;
            ok = 1 ;
        }
        else break ;
    }
   }
   // Second Option to choose number
   i = 0 , j = 1 , ok = -1 ;
   while(1){
    if(ok == -1){
        if(i < odd.size()){
            RoySecond += odd[i] ;
            if(i + 1 < odd.size()) HridoySecond += odd[i + 1] ;
            i += 2 ;
            ok = 1 ;
        }
        else break ;
    }
    else if(ok == 1){
        if(j < even.size()){
            RoySecond += even[j] ;
            if(j + 1 < even.size()) HridoySecond += even[j + 1] ;
            j += 2 ;
            ok = 0 ;
        }
        else break ;
    }
    else {
        if(i < odd.size()){
            RoySecond += odd[i] ;
            if(i + 1 < odd.size()) HridoySecond += odd[i + 1] ;
            i += 2 ;
            ok = 1 ;
        }
        else break ;
    }
   }
   cout << (RoyFirst <= HridoyFirst && RoySecond <= HridoySecond ? "Hridoy\n" : "Roy\n") ;

}
int main()
{
     __Heart__
     int t ; cin >> t ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1102 Odd-Even Game
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-28 12:57:11
Judged At
2024-10-03 22:27:58
Judged By
Score
1
Total Time
22ms
Peak Memory
1.246 MiB