제민
17281 ⚾ 본문
https://www.acmicpc.net/problem/17281
17281번: ⚾
⚾는 9명으로 이루어진 두 팀이 공격과 수비를 번갈아 하는 게임이다. 하나의 이닝은 공격과 수비로 이루어져 있고, 총 N이닝 동안 게임을 진행해야 한다. 한 이닝에 3아웃이 발생하면 이닝이 종
www.acmicpc.net
막상 풀면 그렇게 어렵지 않은 문제인데, 야구를 잘 몰라서 문제를 이해하는데 시간이 좀 걸렸다.
#include <bits/stdc++.h>
using namespace std;
int N,mx;
int score[53][12]; //이닝 번호, 선수 수
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>N;
for(int i=1;i<=N;i++)
for(int j=1;j<=9;j++)
cin>>score[i][j]; //i번 이닝에서 j번 선수의 기록
vector<int> brute={1,2,3,4,5,6,7,8,9};
do{
if(brute[3]!=1) continue;
int point=0,cur=0;//현재 타자
for(int i=1;i<=N;i++){ //이닝
int out=0;
bool base[4]={0,0,0,0}; //루
while(out<3){
base[0]=true;
int move=score[i][brute[cur++]];
if(cur==9) cur=0;
if(!move){out++; continue;}
for(int j=3;j>=0;j--){
if(!base[j]) continue;
if(j+move>=4) point++;
else base[j+move]=true;
base[j]=false;
}
}
}
mx=max(point,mx);
}while(next_permutation(brute.begin(),brute.end()));
cout<<mx;
return 0;
}
'코테연습일지 > 구현 (시뮬레이션)' 카테고리의 다른 글
17144 미세먼지 안녕! (1) | 2024.02.13 |
---|---|
4991 로봇 청소기 (1) | 2024.02.12 |
14890 경사로 (0) | 2024.02.11 |
13460 구슬 탈출 2 (1) | 2024.02.11 |
14500 테트로미노 (2) | 2024.02.10 |