NC205340. YetAnotherStonesGame
描述
输入描述
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains an one integer N (2 ≤ N ≤ 50), indicating the number of the piles.
The second line contains N numbers , ,……, (1 ≤ ≤ 50), indicating the number of the stones in the i-th pile.
输出描述
For each case, output "Happy Little Gyro"(without quotes) if Little Gyro wins the game, Otherwise, output "Sad Little Gyro"(without quotes).
示例1
输入:
2 2 8 8 4 3 1 4 1
输出:
Sad Little Gyro Happy Little Gyro
C++ 解法, 执行用时: 3ms, 内存消耗: 380K, 提交时间: 2021-05-24 16:17:29
#include<bits/stdc++.h> using namespace std; int a[55]; int main() { int t, n; cin>>t; while(t--) { cin>>n; for(int i = 1; i <= n; i++) cin>>a[i]; sort(a+1, a+1+n); if(a[1] == a[n/2+1]) cout<<"Sad Little Gyro"<<endl; else cout<<"Happy Little Gyro"<<endl; } return 0; }
C++14(g++5.4) 解法, 执行用时: 3ms, 内存消耗: 376K, 提交时间: 2020-09-18 16:45:00
#include<bits/stdc++.h> using namespace std; int sz[55]; int main() { int t; cin>>t; while(t--) { int n; cin>>n; for(int i=0;i<n;i++) { cin>>sz[i]; } sort(sz,sz+n); if(sz[0]==sz[n/2]) { cout<<"Sad Little Gyro\n"; } else { cout<<"Happy Little Gyro\n"; } } }