전공공부/코딩테스트
(c++) 1209) Sum
by 시아나
2022. 5. 28.
https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=1&problemLevel=2&problemLevel=3&contestProbId=AV13_BWKACUCFAYh&categoryId=AV13_BWKACUCFAYh&categoryType=CODE&problemTitle=&orderBy=RECOMMEND_COUNT&selectCodeLang=CCPP&select-1=3&pageSize=10&pageIndex=3
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
for (int t = 1; t <= 10; t++) {
int T; cin >> T;
vector<vector<int>> board;
vector<int> row(100,0), col(100,0), line(2,0);
for (int i = 0; i < 100; i++) {
vector<int> list;
for (int k = 0; k < 100; k++) {
int n; cin >> n;
list.push_back(n);
row[i] += n;
col[k] += n;
}
board.push_back(list);
line[0] += board[i][i];
line[1] += board[i][99 - i];
}
int maxRow = *max_element(row.begin(), row.end());
int maxCol = *max_element(col.begin(), col.end());
int maxLine = *max_element(line.begin(), line.end());
int best = max(maxRow, max(maxCol, maxLine));
cout << "#" << T << " " << best << endl;
}
return 0;
}