Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #7684
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main(){
- int n, mch = -1, mnch = -1;
- cin >> n;
- for(int x,i = 0; i < n; i++){
- cin >> x;
- if(x % 2 == 0 && x > mch){
- mch = x;
- }
- if(x % 2 != 0 && x > mnch){
- mnch = x;
- }
- }
- int r;
- cin >> r;
- if(mch == -1 || mnch == -1){
- cout << "Вычисленное контрольное значение: " << -1 << endl;
- if(r == -1){
- cout << "Контроль пройден" << endl;
- }else{
- cout << "Контроль не пройден" << endl;
- }
- }else{
- cout << "Вычисленное контрольное значение: " << mch + mnch << endl;
- if(r == mch + mnch){
- cout << "Контроль пройден" << endl;
- }else{
- cout << "Контроль не пройден" << endl;
- }
- }
- return 0;
- }
- #7772
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main(){
- int n,max8, maxp = 0;
- cin >> n;
- int a[7];
- cin >> max8;
- for(int i = 0; i < 7; i++){
- cin >> a[i];
- }
- for(int x,i = 7; i < n; i++){
- cin >> x;
- if(x * max8 > maxp){
- maxp = x * max8;
- }
- if(a[0] > max8){
- max8 = a[0];
- }
- a[0] = a[1];
- a[1] = a[2];
- a[2] = a[3];
- a[3] = a[4];
- a[4] = a[5];
- a[5] = a[6];
- a[6] = a[7];
- a[7] = x;
- }
- cout << maxp;
- return 0;
- }
- #7799
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main(){
- int n,min4, mins = 20002;
- cin >> n;
- cin >> min4;
- int a[3];
- for(int i = 0; i < 3; i++){
- cin >> a[i];
- }
- for(int x,i = 4; i < n; i++){
- cin >> x;
- if(x + min4 < mins){
- mins = x + min4;
- }
- if(a[0] < min4){
- min4 = a[0];
- }
- a[0] = a[1];
- a[1] = a[2];
- a[2] = a[3];
- a[3] = x;
- }
- cout << mins;
- return 0;
- }
- #hard one
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main(){
- int a[3][3] = {};
- int b[3][3] = {};
- int n;
- cin >> n;
- for(int i = 0; i < n; i++){
- int x;
- cin >> x;
- if(x > a[(i+1)%3][x%3]){
- b[(i+1)%3][x%3] = a[(i+1)%3][x%3];
- a[(i+1)%3][x%3] = x;
- }else if(x > b[(i+1)%3][x%3]){
- b[(i+1)%3][x%3] = x;
- }
- }
- int first = max(a[0][0] + b[0][0],max(a[0][1] + b[0][2], a[0][2] + b[0][1]));
- int sec = max(a[1][0] + b[2][0],max(a[1][1] + b[2][2], a[1][2] + b[2][1]));
- int third = max(a[2][0] + b[1][0],max(a[2][1] + b[1][2], a[2][2] + b[1][1]));
- int mmax = max(first,max(sec,third));
- int maxa = max(a[0][1] + a[0][2],max(a[1][1] + a[2][2],a[2][1]+a[1][2]));
- maxa = max(maxa,a[1][0]+a[2][0]);
- int maxb = max(b[0][1] + b[0][2],max(b[1][1] + b[2][2],b[2][1]+b[1][2]));
- maxb = max(maxb,b[1][0]+b[2][0]);
- cout << max(mmax,max(maxa,maxb));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement