스웨덴의 대학교에서 개최하는 대회의 본선 이전에 연습하는 대회이다.

연습 대회이긴 하지만 문제 질도 괜찮고, 난이도도 상당하기에 후기를 올린다.

sitstar2021.contest.codeforces.com/group/1HLBM0lmlk/contests

 

Login - Codeforces

 

sitstar2021.contest.codeforces.com

여기서 대회를 볼 수 있다.(대회 진행중에는 볼 수 없는 것으로 알고 있다)

일단 문제는 12문제인데, 나는 그 중 8개를 풀었다.

8개 모두 풀이를 작성하고, 짧은 것은 이어서, 긴 것은 따로 풀이를 포스팅해 링크를 여기에 모아두도록 하겠다.

에디토리얼은 영어로 작성했다

시작하자!

 

 

A~D = ilc12345-080.tistory.com/57

 

SIT Contest A, B, C, D Editorial

A. Arithmetic sitstar2021.contest.codeforces.com/group/1HLBM0lmlk/contest/309373/problem/A Login - Codeforces sitstar2021.contest.codeforces.com (sol) You need to print 'Yes' if a*b==c or b*c==a or..

ilc12345-080.tistory.com

 

나머지는 더 쓸 예정..

쓰는대로 업데이트하겠습니다

A. Arithmetic

<problem link>

sitstar2021.contest.codeforces.com/group/1HLBM0lmlk/contest/309373/problem/A

 

Login - Codeforces

 

sitstar2021.contest.codeforces.com

(sol)

You need to print 'Yes' if a*b==c or b*c==a or c*a==b.

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0)
typedef long long ll;
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		if(a*b==c)
		{
			puts("YES");
			printf("%d %d %d\n",a,b,c);
		}
		else if(b*c==a)
		{
			puts("YES");
			printf("%d %d %d\n",b,c,a);
		}
		else if(c*a==b)
		{
			puts("YES");
			printf("%d %d %d\n",c,a,b);
		}
		else puts("NO");
	}
	return 0;
}

 

B. Fair Division

<problem link>

sitstar2021.contest.codeforces.com/group/1HLBM0lmlk/contest/309373/problem/B

 

Login - Codeforces

 

sitstar2021.contest.codeforces.com

(sol)

If n is dividable by 3, you need to print 'a/3-1', 'a/3', and 'a/3+1'.

If not, the answer does not exist. Print '-1'.

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0)
typedef long long ll;
using namespace std;

int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int a;
		scanf("%d",&a);
		if(a%3==0)
		{
			int k=a/3;
			printf("%d %d %d\n",k-1,k,k+1);
		}
		else puts("-1");
	}
	return 0;
}

 

C. Baking

<problem link>

sitstar2021.contest.codeforces.com/group/1HLBM0lmlk/contest/309373/problem/C

 

Login - Codeforces

 

sitstar2021.contest.codeforces.com

(sol)

You can compare |a-b| and |a-c|.

If |a-b| is smaller, print |a-b|+|b-c|.

Else, print |a-c|+|b-c|.

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0)
typedef long long ll;
using namespace std;

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(abs(a-b)<=abs(a-c))
	{
		printf("%d",abs(a-b)+abs(b-c));
	}
	else
	{
		printf("%d",abs(a-c)+abs(c-b));
	}
	return 0;
}

 

D. Cheese Factory

<problem link>

sitstar2021.contest.codeforces.com/group/1HLBM0lmlk/contest/309373/problem/D

 

Login - Codeforces

 

sitstar2021.contest.codeforces.com

(sol)

You can conduct a greedy solution.

Use the container that can contain the most for the customer that buys the most, and vice versa.

Therefore, you need to print the sum of the multiples of the first, second, and third biggest numbers in the sequence a[i] and b[i].

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0)
typedef long long ll;
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int a,b,c,d,e,f;
		scanf("%d %d %d\n%d %d %d",&a,&b,&c,&d,&e,&f);
		int m1,m2,m3,n1,n2,n3;
		m1=max3(a,b,c);
		m3=min3(a,b,c);
		m2=a+b+c-m1-m3;
		n1=max3(d,e,f);
		n3=min3(d,e,f);
		n2=d+e+f-n1-n3;
		printf("%d\n",m1*n1+m2*n2+m3*n3);
	}
	return 0;
}

 

 

 

내가 한 엣코더 라운드 중에 가장 잘한 라운드다!

3솔했고, B에서 많이 뇌절했다.

B는 문제가 좀 별로인것 같다.

그리고 C번은 왤논이었는데 내가 그걸 모르고(...) 엄청 어렵게 풀었다.

풀이로 들어가자!

 

A. Slot

Problem Statement

You are playing the slots.

The result of a spin is represented by three uppercase English letters ,  and . It is considered a win when all of them are the same letter.

Determine whether it is a win.

Constraints

 is an uppercase English letter.

Input

Input is given from Standard Input in the following format:

Output

If the result is a win, print Won; otherwise, print Lost.

풀이

주어진 세개의 문자가 같은지를 판별하자.

#include<bits/stdc++.h>
int main(){
	char a,b,c;
	scanf("%c %c %c",&a,&b,&c);
	if(a==b&&a==c&&b==c) puts("Won");
	else puts("Lost");
	return 0;
}

[01:21 Accepted]

 

B. Alchoholic

Problem Statement

Takahashi had  glasses of liquor.

The amount and alcohol percentage of the i-th liquor were Vi milliliters and Pi percent by volume, respectively.

Takahashi gets drunk when his alcohol intake exceeds X milliliters.

Which of the N liquors was he drinking when he gets drunk? If he was not drunk even after drinking all the liquors, print -1 instead.

Constraints

  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

 

Output

If Takahashi got drunk when drinking the i-th liquor, print i. If he was not drunk even after drinking all the liquors, print -1 instead.

풀이

각 주어지는 음료별로 알코올의 양을 구해서 더하면 된다.

그대로 코드를 짜고 제출하면 틀린다.

왜그럴까? 바로 실수 오차 때문이다.

실수 오차를 없엘려면 실수를 없에 버리면 된다.

따라서 알코올의 양을 100으로 나누지 않고, 즉 알코올의 양*100을 구하고 그 값을 마실수 있는 최대 알코올의 양*100과 비교해주면 된다.

실수오차 참 짜증난다:(

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, x;cin >> n >> x;
    int v[1000], p[1000];
    for (int i = 0; i < n; ++i) cin >> v[i] >> p[i];
    long long t[1000];
    for (int i = 0; i < n; ++i) t[i] = v[i] * p[i];
    long long ans = 0;
    for (int i = 0; i < n; ++i){
        ans += t[i];
        if (ans > x * 100){
            cout << i+1 << endl;
            break;
        }
    }
    if (ans <= x * 100) cout << -1;
}

[13:00 Wrong answer]

[15:07 Wrong answer]

[18:23 Wrong answer]

[25:29 Wrong answer]

[27:52 Wrong answer]

[30:25 Accepted]

 

C. Mandarine Orange

Problem Statement

There are N dishes arranged in a row in front of Takahashi. The i-th dish from the left has Ai oranges on it.

Takahashi will choose a triple of integers (l,r,x) satisfying all of the following conditions:

  • for every integer I between  and  (inclusive), x≤Ai.

He will then pick up and eat x oranges from each of the l-th through r-th dishes from the left.

At most how many oranges can he eat by choosing the triple (l,r,x) to maximize this number?

Constraints

  • All values in input are integers.

 

Input

Input is given from Standard Input in the following format:

AN

Output

Print the maximum number of oranges Takahashi can eat.

풀이

이 문제는 왜인지 모르겠지만 왤논이라고 한다,,

나는 대회 중에 진짜 이상한 방법으로 풀어서 11분만에 템플릿 미포함 1442B를 짜는 미친짓을 했다.

여러분은 이런 풀이를 하지 않았으면 한다.. ㅠㅠㅠ

내 풀이를 설명하면 머리만 아프니까 에디토리얼에 있는 간단한 풀이를 설명하도록 하겠다.

One can first fix l, then update  while increasing  one by one to find them in a total of  time.

아 너무 쉽다

 

<에디토리얼 코드>

#include<bits/stdc++.h>
using namespace std;
int a[10010];
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++)cin >> a[i];
	int ans=0;
	for(int l=0;l<n;l++){
		int x=a[l];
		for(int r=l;r<n;r++){
			x=min(x,a[r]);
			ans=max(ans,x*(r-l+1));
		}
	}
	cout << ans;
}

 

<내 코드>

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<ll> f(vector<ll> &v){
	ll i,j,k,l,n=v.size();
	vector<ll> res(n);stack<ll> st;
	for(i=0;i<n;i++){
		while(!st.empty()&v[i]<=v[st.top()]) st.pop();
		if(st.empty()) res[i]=-1;
		else res[i] = st.top();
		st.push(i);
	}
	return res;
}
vector<ll> g(vector<ll> &v){
	ll i,j,k,l,n=v.size();vector<ll> res(n);stack<ll> st;
	for(i=n-1;i>=0;i--){
		while(!st.empty()&v[i]<=v[st.top()]) st.pop();
		if(st.empty()) res[i]=n;
		else res[i] = st.top();
		st.push(i);
	}
	return res;
}
void solve(){
	ll i,j,k,n,m,a,b,u;cin>>n;vector<ll> v(n);
	for(i=0;i<n;i++) cin>>v[i];
    vector<ll> l = f(v);vector<ll> r = g(v); ll ans=0;
    for(i=0;i<n;i++) ans = max(ans, v[i]*(r[i]-l[i]-1));
    cout<<ans;
}
int main(){
    ll t;t=1;
    while(t--) solve();
}

제 코드가 얼마나 더러운지 알겠나요

[41:55 Accepted]

 

 

D 굉장히 어려워 보여서 안풀었다 ㅋㅋㅋㅋ

업솔빙도 안할예정

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

Atcoder Beginner Contest 186  (1) 2020.12.26
Atcoder Beginner contest 185 후기  (0) 2020.12.19
ABC 184 후기  (0) 2020.11.23

백준에서 개최되었던 대회이다.

백준 대회에서 처음으로 3솔 해서 간단하게나마 블로그에 정리해 본다.

푼 문제가 다 브론즈다 ㅠㅠ

시작하자마자 문제를 풀었고, 푸는 속도도 나름 괜찮았는지 초반에는 등수가 상당히 작은 한자리 수였다.

4등까지 올라갔던 것 같다.

하지만 시간이 지나면서 고수분들은 어려운 문제들을 척척 푸시고, 나는 그러지 못해서 결국은 등수가 큰 2자리 수로 내려갔다 ㅠㅠ

그럼 풀이로 들어가자.

 

PA. 세금

-> 간단한 수학 문제이다.

-> 문제에서 전체 상금의 22%를 제세공과금으로 납부하는 경우와 상금의 80%를 필요 경비로 인정받고, 나머지 금액        중 22%만을 제세공과금으로 납부하는 경우의 수령 금액을 구하라고 했는데, 이를 수학으로 풀면 된다.

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",n-(n*22/100),n-(n*20/100)*22/100);
}

[00:03 맞았습니다!]

 

이 문제에서 처음에 너무 복잡하게 생각해서 코드를 이상하게 짜는 바람에 1번 미스가 나서 시간을 너무 많이 쏟아 버렸다.

쉬운 문제는 쉽게 생각해야 한다. 이것은 코포 div.3에서도 적용된다.

(나는 자꾸 쉬운 문제를 어렵게 생각하고 긴장해서 1분만에 풀 것을 10분도 넘게 걸린다 ㅠㅠ)

PA번 다음 문제는 PB번인데, 내가 PB번을 봤을 때 첫인상이 너무 어려워 보였다.

그래서 다음 문제들을 슥 훑어보던 도중 굉장히 쉬운 문제를 또 찾게 되었는데, 바로 D번이다.

D번을 빨리 찾은 것이 신의 한 수였다.

 

D. Darius님 한타 안 함?

-> 역시 간단한 문제이다.

-> 조건문으로 a+c<b 또는 b=0 이면 hasu를 출력하고, 아니면 gosu를 출력하면 된다.

#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d/%d/%d",&a,&b,&c);
    if(a+c<b||b==0) puts("hasu");
    else puts("gosu");
}

[00:05 맞았습니다!]

 

이 문제를 푸는데 걸린 시간이 PA번 푸는데 걸린 시간보다 짧다,,

그만큼 PA에서 긴장한 것 같다.

이 문제를 품으로써 나는 비록 초반이지만 5분만에 2문제를 푼 상위권으로 올라가게 되었다.

그리고 다른 문제들을 스캔하던 중 E번이 눈에 들어와서 고민을 해 보았다.

하지만 아무리 생각해도 답이 나오질 않아서 포기하고 J번을 보았더니 조합 문제였다.

교란순열 관련 문제여서 간단하게 짜서 컴파일러에서 돌려보니 정답이 잘 나와서 제출하려는 순간..

뭔가 큰 테케에서 틀릴 것 같았다.

내 감은 틀리지 않았고, 최대치를 입력해본 결과 실행시간이 압도적으로 길어졌다.

그래서 어떻게 하면 교란순열 구하는 과정을 최적화할 수 있을 까 고민하다가 그냥 포기하고 공부하러 들어갔다.

그리고 대회 시작 약 2시간 후에 나와서 다시 문제를 훑어보는데..

뭔가PC번에서 느낌적인 느낌으로 두 문자열의 길이를 더한 것이 답일 것 같았다.

그래서 PC번을 풀게 되었다(...)

 

PC. 스시

-> 처음 볼 때는 상당히 어려워 보인다.

-> 하지만 문제를 잘 관찰해 보면 두 문자열의 길이를 더한 것이 답이 됨을 알 수 있다.

#include<stdio.h>
#include<string.h>
int main()
{
    int n,cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        char str[101];
        scanf("%s",str);
        cnt+=strlen(str);
    }
    printf("%d",cnt);
}

[02:32 맞았습니다!]

 

진짜 감이 잘 들어맞은 문제였다.. ㄷㄷ

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

KOI 오픈 컨테스트 후기  (0) 2020.11.16

 

A랑 B 빨리 풀었다고 신났다가 망함..;;

바로 풀이로 들어가자.

 

A. Brick

Problem Statement

We have a truck, which can carry at most kilograms.

We will load bricks onto this truck, each of which weighs  kilograms. At most how many bricks can be loaded?

 

Constraints

  • 1≤N,W≤1000
  •  and  are integers.

Input

Input is given from Standard Input in the following format:

N W

Output

Print an integer representing the maximum number of bricks that can be loaded onto the truck.

풀이

n 킬로그램까지 실을 수 있는 트럭에 w킬로그램 나가는 물건을 얼마나 실을 수 있는지 물어보는 문제이다.

C, C++에서는 그냥 나누면 되고, 파이썬은 정수 나눗셈을 이용한 풀이를 할 수 있다.

정말 쉬운 문제이고, 27초 만에 풀어서 그때 스코어보드 97등이었다. XD

A번 최고기록

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

[00:27 Accepted]

 

B. Blocks on Grid

Problem Statement

We have a grid with  horizontal rows and vertical columns. The square at the i-th row from the top and j-th column from the left has Ai,j blocks stacked on it.

At least how many blocks must be removed to make all squares have the same number of blocks?

Constraints

  • 1≤H,W≤100

Input

Input is given from Standard Input in the following format:

W

A1,1  

AH,1 AH,2 AH,W

Output

Print the minimum number of blocks that must be removed.

풀이

모든 블럭의 개수를 체크해서 가장 작은 값으로 만들어야 한다. 따라서 모든 블럭의 개수만큼 반복문을 돌리고, 해당 칸의 블록의 개수에서 가장 적은 블록의 개수를 뺀 것들의 합이 정답이 된다.

#include<stdio.h>
int main()
{
    int a,b,min = 99999999,i,j;
    int sum=0;
    int arr[1001][1001];
    scanf("%d%d",&a,&b);
    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
        {
            scanf("%d",&arr[i][j]);
            if(arr[i][j]<min)
            {
                min = arr[i][j];
            }
        }
    }
    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
        {
            sum = sum + (arr[i][j]-min);
        }
    }
    printf("%lld",sum);
    return 0;
}

[04:12 Accepted]

 

 

여기까지는 나의 ABC 최고기록이었다.

그리고 C, D, E에서 동시에 뇌절하는 바람에 더 못풀었다... ㅠㅠㅠ

 

C, D업솔빙 예정

 

UPD : C업솔빙 완료

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

AtCoder Beginner Contest 189 후기  (0) 2021.01.24
Atcoder Beginner contest 185 후기  (0) 2020.12.19
ABC 184 후기  (0) 2020.11.23

+ Recent posts