-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.cpp
More file actions
70 lines (68 loc) · 1.69 KB
/
Copy path1.cpp
File metadata and controls
70 lines (68 loc) · 1.69 KB
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
#include <iostream>
using namespace std;
int main(){
int n,c3,bales[101],temp,best=-99999,c=0,ce=1,left,right,t=0,c2;
cin >> n;
for(int c1=1;c1<=n;c1++){
cin >> bales[c1];
}
for(int c1=0;c1<n;c1++){
for(int c2=1;c2<=n-1;c2++){
if(bales[c2]>bales[c2+1]){
temp=bales[c2];
bales[c2]=bales[c2+1];
bales[c2+1]=temp;
}
}
}
for(int c1=1;c1<=n;c1++){
left=c1;
right=c1;
while(left!=-1){
cout << "L:" << c1 << " " << bales[left] << " " << ce << " " << best << endl;
if(c1==1){
left=-1;
break;
}
for(c2=left;c2>=1;c2--){
if(bales[c2]>=bales[left]-ce){
t=1;
ce++;
c++;
}
}
left=c2;
if(t==0){
left=-1;
}
t=0;
}
ce=1;
t=0;
while(right!=-1){
cout << "R:" << c1 << " " << bales[right] << " " << ce << " " << best << endl;
if(c1==n){
right=-1;
break;
}
for(c3=right;c3<=n;c3++){
if(bales[c3]<=bales[right]+ce){
c++;
t=1;
ce++;
}
}
right=c3;
if(t==0){
right=-1;
}
t=0;
}
ce=1;
if(c>best){
best=c;
}
c=0;
}
cout << best << endl;
}