-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotu.cpp
85 lines (71 loc) · 1.14 KB
/
motu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
// Sample code to perform I/O:
#include <iostream>
using namespace std;
int main() {
int num;
cin >> num; // Reading input from STDIN
cout << "Input number is " << num << endl; // Writing output to STDOUT
}
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/
// Write your code here
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf =1e18;
#define fr(n) for(ll i = 0 ; i < n ; i++)
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n,p=0,m=0,pt=0,mt=0;
cin>>n;
ll a[n+4];
fr(n)
cin>>a[i];
ll j=n-1;
pt=2*a[j];
mt+=a[0];
m++;
p++;
ll mi=0,pi=j;
fr(n){
if(mt>pt){
while(j>mi)
{
pi=j;
if(pt>=mt)
break;
j--;
pt+=2*a[j];
if(j!=mi)
p++;
}
}
else {
while(i<pi)
{
mi=i;
if(mt>pt)
break;
i++;
mt+=a[i];
if(i!=pi)
m++;
}
}
// cout<<i<<endl;
}
cout<<m<<" "<<p<<endl;
if(m==p)
cout<<"Tie"<<endl;
else if(m>p)
cout<<"Motu"<<endl;
else
cout<<"Patlu"<<endl;
}
return 0;
}