일요일 9시에 열리는 대회는 내가 일정이 있어서 풀 시간이 얼마 없다..ㅠ

그래도 괜찮은(?) 결과가 나와서 기분은 좋았지만 rating은...다.

개인적으로 B번을 시간 안에 못 풀기도 했고, C번은 내가 좋아하는 조합이론 문제가 나와서 대회가 마음에 들었다.

(참고로 내가 가장 좋아하는 문제의 종류는 조합/기하 관련 문제들이다)(물론 쉬운거)

바로 풀이로 들어가자.

 

A. ABC Preparation

Problem statement

Takahashi has decided to hold some number of programming contests.
Holding one contest requires one 100-point problem, one 200-point problem, one 300-point problem, and one 400-point problem.
When he has , ,  and  drafts of -, -, -, and -point problems, respectively, at most how many contests can he hold?
The same draft can be used only once.

 

Input

Input is given from Standard Input in the following format:

A1 A2 A3 A4

 

Output

Print an integer representing the maximum number of contests that can be held.

풀이

어짜피 모든 배점의 문제를 다 똑같은 개수만큼 출제하는 것이기 때문에 가장 적은 개수가 있는 문제의 개수만큼만 대회를 만들 수 있다. 따라서 입력되는 값 중에서 가장 작은 값을 출력하면 된다.

#include<stdio.h>
int min(int a, int b){if(a>=b){return b;}else{return a;}}
int main()
{
    int a,b,c,d,;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    printf("%d",min(a,min(b,min(c,d))));
    return 0;
}

[02:29 Accepted]

 

C. Duodecim Ferra

Problem statement

There is an iron bar of length  lying east-west. We will cut this bar at  positions to divide it into  bars. Here, each of the  resulting bars must have a positive integer length.
Find the number of ways to do this division. Two ways to do the division are considered different if and only if there is a position cut in only one of those ways.
Under the constraints of this problem, it can be proved that the answer is less than .

 

Input

Input is given from Standard Input in the following format:

L

 

Output

Print the number of ways to do the division.

 

풀이

길이가 L인 bar에는 자를 수 있는 곳이 L-1개 있다. 그 L-1개 중에서 11개를 선택하는 방법의 수가 정답이므로 L-1C11을 출력하면 된다.

import math
def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)
a = int(input())
print(nCr(a-1,11))

다름이 아니라 C로 짜니까 nCr함수에서 오류가 나는지 자꾸 WA 떠서 파이썬으로 풀었다

[67:12 Wrong Answer]

[67:26 Wrong Answer]

[73:55 Runtime Error]

[76:21 Accepted]

 

B는 업솔빙 예정

 

 

 

'대회 후기 > Atcoder' 카테고리의 다른 글

AtCoder Beginner Contest 189 후기  (0) 2021.01.24
Atcoder Beginner Contest 186  (1) 2020.12.26
ABC 184 후기  (0) 2020.11.23

조금 늦게 후기를 작성한다.

이 라운드는 한국인인 djm03718님이 주최하셔서 굉장히 기대가 되었다.

시간도 한국인에 맞게 1시간 이른 10시 35분이어서 좋았다.

그래도 한문제밖에 못풀었다.

바로 풀이로 들어가도록 하겠다.

 

A. Cancel the trains

Problem statement

Gildong's town has a train system that has 100 trains that travel from the bottom end to the top end and 100 trains that travel from the left end to the right end. The trains starting from each side are numbered from 11 to 100, respectively, and all trains have the same speed. Let's take a look at the picture below.

The train system can be represented as coordinates on a 2D plane. The i-th train starting at the bottom end is initially at (i,0) and will be at (i,T) after T minutes, and the i-th train starting at the left end is initially at (0,i) and will be at (T,i) after T minutes. All trains arrive at their destinations after 101 minutes.

However, Gildong found that some trains scheduled to depart at a specific time, simultaneously, are very dangerous. At this time, n trains are scheduled to depart from the bottom end and mm trains are scheduled to depart from the left end. If two trains are both at (x,y) at the same time for some x and y, they will crash into each other. Therefore, he is asking you to find the minimum number of trains that should be canceled to prevent all such crashes.

**문제에 오타가 있습니다. Bold로 표시한 'canceled'가 문제 지문에서는 'cancelled'로 표기되어 있습니다.**

 

Input

Each test contains one or more test cases. The first line contains the number of test cases t (1≤t≤100).

Each test case contains three lines. The first line of each test case consists of two integers n and m (1≤n,m≤100) — the number of trains scheduled to depart from the bottom end, and the number of trains scheduled to depart from the left end, respectively.

The second line of each test case contains n integers. Each integer is a train number that is scheduled to start from the bottom end. The numbers are given in strictly increasing order, and are between 1 and 100, inclusive.

The third line of each test case contains mm integers. Each integer is a train number that is scheduled to start from the left end. The numbers are given in strictly increasing order, and are between 1 and 100, inclusive.

 

Output

For each test case, print a single integer: the minimum number of trains that should be canceled in order to prevent all crashes.

풀이

두개의 기차가 충돌하게 되는 조건은 같은 시간에 같은 위치에서 출발한 경우가 된다.

따라서 입력되는 2개의 배열에서 같은 숫자가 나오는 횟수를 출력하면 된다.

 

#include<stdio.h>
int main()
{
    int i,j,n,m,t,train[101],train2[101],cnt=0;
    scanf("%d\n",&t);
    while(t--)
    {
        scanf("%d %d\n",&n,&m);
        for(i=0;i<n;i++)
        {
            scanf("%d",&train[i]);
        }
        for(j=0;j<m;j++)
        {
            scanf("%d",&train2[j]);
        }
        cnt=0;
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                if(train[i]==train2[j]) cnt++;
                else continue;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

[00:09 Pretest Passed(3)/Accepted]

 

한 문제만 풀었다.

B번 업솔빙 예정..

'대회 후기 > Codeforces' 카테고리의 다른 글

SIT STAR Contest 2021 practice  (0) 2021.02.08
SIT Contest A, B, C, D Editorial  (0) 2021.02.08
Codeforces Round 690 (Div.3) 후기  (0) 2020.12.20
Codeforces Round #687 (Div. 2) 후기  (2) 2020.12.01
Codeforces Round #686 (Div.3) 후기  (0) 2020.11.25

전혀 몰랐는데 오늘이 수능이란다...(물론 내가 수능을 본다는건 아니다)

수험생들 화이팅

+ Recent posts