-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathequlaSt.cpp
More file actions
54 lines (51 loc) · 894 Bytes
/
Copy pathequlaSt.cpp
File metadata and controls
54 lines (51 loc) · 894 Bytes
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
#include<iostream>
#define max 100
using namespace std;
int top1=-1;
int top2=-1;
int top3=-1;
int main()
{
int n1,n2,n3;
cin>>n1>>n2>>n3;
long int st1[100001],st2[100001],st3[100001],i,s1=0,s2=0,s3=0;
for(i=n1-1;i>=0;i--)
{
top1=top1+1;
cin>>st1[i];
s1=s1+st1[i];
}
for(i=n2-1;i>=0;i--)
{
top2=top2+1;
cin>>st2[i];
s2=s2+st2[i];
}
for(i=n3-1;i>=0;i--)
{
top3=top3+1;
cin>>st3[i];
s3=s3+st3[i];
}
cout<<top1<<top2<<top3;
while(top1!=-1 && top2!=-1 && top3!=-1)
{
cout<<" start "<<s1<<" "<<s2<<" "<<s3<<"\n";
if(s1==s2 && s3==s2)
break;
if(s1>=s2 && s1>=s3){
s1=s1-st1[top1];
top1 =top1-1;}
else if(s2>=s1 && s2>=s3){
s2=s2-st2[top2];
top2=top2-1;}
else if(s3>=s1 && s3>=s2){
s3 = s3-st3[top3];
top3=top3-1;}
cout<<" end "<<s1<<" "<<s2<<" "<<s3<<"\n";
}
if(s1==0||s2==0||s3==0)
cout<<0;
else
cout<<s1<<"\n";
}