Skip to content

Commit bd3085d

Browse files
authored
More algo for the gredy method
1 parent dd58e7b commit bd3085d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

1154A.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include<iostream>
2+
#include<algorithm>
3+
using namespace std;
4+
5+
int main(){
6+
int v1[100];
7+
for(int i=0;i<4;i++){
8+
cin>>v1[i];
9+
}
10+
sort(v1,v1+4);
11+
cout << v1[3]-v1[0] << " " << v1[3]-v1[1] << " " << v1[3]-v1[2] << endl;
12+
13+
}

96A.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<iostream>
2+
#include<algorithm>
3+
//#include<conio.h>
4+
5+
using namespace std;
6+
7+
int main(){
8+
string s1;
9+
cin>>s1;
10+
int i;
11+
int ones;
12+
int zeros;
13+
bool flag;
14+
for(i =0;i<s1.length();i++){
15+
ones = count(s1.begin()+i,s1.begin()+i+7,'1');
16+
zeros = count(s1.begin()+i,s1.begin()+i+7,'0');
17+
if(ones >= 7 || zeros >= 7){
18+
flag =true;
19+
}
20+
}
21+
if(flag){
22+
cout<<"YES"<<endl;
23+
}else{
24+
cout<<"NO"<<endl;
25+
}
26+
}

0 commit comments

Comments
 (0)