# JONRPS Editorials

Contest

Setter: sayan_kashyapi

Tester: mishra_roshan

Editorialist: shaw_sandeep

Simple

# PREREQUISITES:

Conditional Logic of Stone-Paper-Scissors Game

# PROBLEM:

Given a occurence of stone-paper-scissor of two player as R1,P1,S1 (Jon) and R2,P2,S2 (Jon’s friend) respectively. To find out if Jon can win the game if he plays optimally such that the score is atleast ceil(N/2) rounds.

# EXPLANATION

In this game we know that:

1. Paper beats Rock

2. Scissors beat Paper

3. Rock beats Scissors

For Jon to win ( He always plays after his friend ), we must find his optimal score which is the sum of minimum of (R2,P1), (P2,S1) and (S2,R1)

If the score is more than N/2 then display “Yes” for winning else display “No”

# TIME COMPLEXITY

Time complexity is O(1) for each test-case.

# SOLUTIONS:

Setter's Solution
C++
``````
#include<bits/stdc++.h>

using namespace std;

void solve(){

int n, a1, b1, c1, a2, b2, c2;

cin >> n >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;

if (min(a1, c2) + min(b1, a2) + min(c1, b2) > n / 2)

cout << "Yes\n";

else

cout << "No\n";

}

int main(){

int t;

cin >> t;

while (t--){

solve();

}

return 0;

}

``````
Tester's Solution
C++
``````
#include <bits/stdc++.h>

using namespace std;

int main() {

int t;

scanf("%d", &t);

while (t--) {

long long n;

scanf("%lld", &n);

long long r1, p1, s1;

scanf("%lld %lld %lld", &r1, &p1, &s1);

long long r2, p2, s2;

scanf("%lld %lld %lld", &r2, &p2, &s2);

long long score = min(r2, p1) + min(p2, s1) + min(s2, r1);

if (score > ceil(n / 2)) {

printf("Yes\n");

} else printf("No\n");

}

return 0;

}

``````

Feel free to Share your approach.

Suggestions are welcomed as always had been.