/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 2ms 532.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 324.0 KiB
#7 Accepted 1ms 324.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 320.0 KiB
#10 Accepted 2ms 532.0 KiB

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

void solve(int cs) {
  int n, m;
  cin >> m >> n;

  vector<vector<int>> M(7, vector<int>(m)), N(7, vector<int>(n));
  for (int i = 0; i < 7; i++) {
    for (int j = 0; j < m; j++) {
      cin >> M[i][j];
    }
  }

  for (int i = 0; i < 7; i++) {
    for (int j = 0; j < n; j++) {
      cin >> N[i][j];
    }
  }

  pair<int, int> mah = {0, 0}, nay = {0, 0};
  int64_t cnt = 0, sum = 0;
  ;
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < 7; i++) {
      if (M[i][j] > 0) {
        sum += M[i][j], cnt += 1;
      } else {
        if (mah.first < cnt) {
          mah.first = cnt, mah.second = sum;
        } else if (mah.first == cnt) {
          if (mah.second < sum) {
            mah.second = sum;
          }
        }
        sum = 0, cnt = 0;
      }
    }
  }
  if (mah.first < cnt) {
    mah.first = cnt, mah.second = sum;
  } else if (mah.first == cnt) {
    if (mah.second < sum) {
      mah.second = sum;
    }
  }
  sum = 0, cnt = 0;
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < 7; i++) {
      if (N[i][j] > 0) {
        sum += N[i][j], cnt += 1;
      } else {
        if (nay.first < cnt) {
          nay.first = cnt, nay.second = sum;
        } else if (nay.first == cnt) {
          if (nay.second < sum) {
            nay.second = sum;
          }
        }
        sum = 0, cnt = 0;
      }
    }
  }
  if (nay.first < cnt) {
    nay.first = cnt, nay.second = sum;
  } else if (nay.first == cnt) {
    if (nay.second < sum) {
      nay.second = sum;
    }
  }
  if (mah.first > nay.first || (mah.first == nay.first && mah.second > nay.second))
    cout << "Mahfuz is the boss\n";
  else if (nay.first > mah.first || (nay.second > mah.second && nay.first == mah.first))
    cout << "Nayon is the boss\n";
  else
    cout << "No one is the boss\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  // cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1017 Solution streak
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-11 12:10:35
Judged At
2024-11-11 03:27:32
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB