Untitled

 avatar
unknown
plain_text
2 years ago
1.2 kB
5
Indexable
#include <bits/stdc++.h>
using namespace std;
string f(int n, int m, priority_queue<int> p, priority_queue<int> q)
{
    while (q.size() != 0 && p.size() != 0)
    {
        int a = q.top();
        int b = p.top();
        if (a > b)
        {
            p.pop();
            q.pop();
            q.push(a - b);
        }
        else if (b > a)
        {
            p.pop();
            q.pop();
            p.push(b - a);
        }
        else
        {
            p.pop();
            q.pop();
        }
    }
    if (q.size() == 0 && p.size() == 0)
        return "Draw";
    else if (q.size() != 0 && p.size() == 0)
        return "Tenzing";
    else
        return "Tsondu";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        priority_queue<int> p;
        priority_queue<int> q;
        int n;
        int m;
        cin >> n >> m;
        for (int i = 0; i < n; i++)
        {
            int e;
            cin >> e;
            p.push(e);
        }
        for (int i = 0; i < m; i++)
        {
            int e;
            cin >> e;
            q.push(e);
        }
        cout << f(n, m, p, q) << '\n';
    }

    return 0;
}
Editor is loading...