Advertisement
EzicMan

reshuege inf c4

Apr 4th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.15 KB | None | 0 0
  1. #7684
  2. #include <iostream>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main(){
  7.     int n, mch = -1, mnch = -1;
  8.     cin >> n;
  9.     for(int x,i = 0; i < n; i++){
  10.         cin >> x;
  11.         if(x % 2 == 0 && x > mch){
  12.             mch = x;
  13.         }
  14.         if(x % 2 != 0 && x > mnch){
  15.             mnch = x;
  16.         }
  17.     }
  18.     int r;
  19.     cin >> r;
  20.     if(mch == -1 || mnch == -1){
  21.         cout << "Вычисленное контрольное значение: " << -1 << endl;
  22.         if(r == -1){
  23.             cout << "Контроль пройден" << endl;
  24.         }else{
  25.             cout << "Контроль не пройден" << endl;
  26.         }
  27.     }else{
  28.         cout << "Вычисленное контрольное значение: " << mch + mnch << endl;
  29.         if(r == mch + mnch){
  30.             cout << "Контроль пройден" << endl;
  31.         }else{
  32.             cout << "Контроль не пройден" << endl;
  33.         }
  34.     }
  35.     return 0;
  36. }
  37.  
  38.  
  39.  
  40. #7772
  41. #include <iostream>
  42. #include <algorithm>
  43. using namespace std;
  44.  
  45. int main(){
  46.     int n,max8, maxp = 0;
  47.     cin >> n;
  48.     int a[7];
  49.     cin >> max8;
  50.     for(int i = 0; i < 7; i++){
  51.         cin >> a[i];
  52.     }
  53.     for(int x,i = 7; i < n; i++){
  54.         cin >> x;
  55.         if(x * max8 > maxp){
  56.             maxp = x * max8;
  57.         }
  58.         if(a[0] > max8){
  59.             max8 = a[0];
  60.         }
  61.         a[0] = a[1];
  62.         a[1] = a[2];
  63.         a[2] = a[3];
  64.         a[3] = a[4];
  65.         a[4] = a[5];
  66.         a[5] = a[6];
  67.         a[6] = a[7];
  68.         a[7] = x;
  69.     }
  70.     cout << maxp;
  71.     return 0;
  72. }
  73.  
  74.  
  75.  
  76. #7799
  77. #include <iostream>
  78. #include <algorithm>
  79. using namespace std;
  80.  
  81. int main(){
  82.     int n,min4, mins = 20002;
  83.     cin >> n;
  84.     cin >> min4;
  85.     int a[3];
  86.     for(int i = 0; i < 3; i++){
  87.         cin >> a[i];
  88.     }
  89.     for(int x,i = 4; i < n; i++){
  90.         cin >> x;
  91.         if(x + min4 < mins){
  92.             mins = x + min4;
  93.         }
  94.         if(a[0] < min4){
  95.             min4 = a[0];
  96.         }
  97.         a[0] = a[1];
  98.         a[1] = a[2];
  99.         a[2] = a[3];
  100.         a[3] = x;
  101.     }
  102.     cout << mins;
  103.     return 0;
  104. }
  105.  
  106. #hard one
  107. #include <iostream>
  108. #include <algorithm>
  109. using namespace std;
  110.  
  111. int main(){
  112.     int a[3][3] = {};
  113.     int b[3][3] = {};
  114.     int n;
  115.     cin >> n;
  116.     for(int i = 0; i < n; i++){
  117.         int x;
  118.         cin >> x;
  119.         if(x > a[(i+1)%3][x%3]){
  120.             b[(i+1)%3][x%3] = a[(i+1)%3][x%3];
  121.             a[(i+1)%3][x%3] = x;
  122.         }else if(x > b[(i+1)%3][x%3]){
  123.             b[(i+1)%3][x%3] = x;
  124.         }
  125.     }
  126.     int first = max(a[0][0] + b[0][0],max(a[0][1] + b[0][2], a[0][2] + b[0][1]));
  127.     int sec = max(a[1][0] + b[2][0],max(a[1][1] + b[2][2], a[1][2] + b[2][1]));
  128.     int third = max(a[2][0] + b[1][0],max(a[2][1] + b[1][2], a[2][2] + b[1][1]));
  129.     int mmax = max(first,max(sec,third));
  130.     int maxa = max(a[0][1] + a[0][2],max(a[1][1] + a[2][2],a[2][1]+a[1][2]));
  131.     maxa = max(maxa,a[1][0]+a[2][0]);
  132.     int maxb = max(b[0][1] + b[0][2],max(b[1][1] + b[2][2],b[2][1]+b[1][2]));
  133.     maxb = max(maxb,b[1][0]+b[2][0]);
  134.     cout << max(mmax,max(maxa,maxb));
  135.     return 0;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement