정화 코딩

[AtCoder] ABC 354 (2024-05-18) 본문

Contest

[AtCoder] ABC 354 (2024-05-18)

jungh150c 2024. 5. 19. 04:42

AtCoder Beginner Contest 354 (https://atcoder.jp/contests/abc354)

 


 

A. Exponential Plant

 

https://atcoder.jp/contests/abc354/tasks/abc354_a

 

//C++

#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int h;
    cin >> h;

    int curh = 0;
    int day = 0;
    int growth = 1;
    while (curh <= h) {
        curh += growth;
        day++;
        growth *= 2;
    }

    cout << day << '\n';
}

(정답)

 


 

B. AtCoder Janken 2

 

https://atcoder.jp/contests/abc354/tasks/abc354_b

 

//C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<string> s;
vector<int> c;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    s = vector<string>(n);
    c = vector<int>(n);
    int t = 0;

    for (int i = 0; i < n; i++) {
        cin >> s[i] >> c[i];
        t += c[i];
    }

    sort(s.begin(), s.end());

    cout << s[t % n] << '\n';
}

(정답)

 


 

C. AtCoder Magics

 

https://atcoder.jp/contests/abc354/tasks/abc354_c

 

//C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<vector<int>> card;

// card의 strength 기준 정렬
bool cmp1(vector<int> &v1, vector<int> &v2) {
    return v1[1] > v2[1];
}

// card의 number 기준 정렬
bool cmp2(vector<int> &v1, vector<int> &v2) {
    return v1[0] < v2[0];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    card = vector<vector<int>>(n, vector<int>(3));

    for (int i = 0; i < n; i++) {
        card[i][0] = i + 1;
        cin >> card[i][1] >> card[i][2];
    }

    sort(card.begin(), card.end(), cmp1);

    int i = 0;
    while (i < card.size()) {
        int j = i + 1;
        while (j < card.size()) {
            if (card[i][2] < card[j][2]) {
                card.erase(card.begin() + j);
            }
            j++;
        }
        i++;
    }

    sort(card.begin(), card.end(), cmp2);

    cout << card.size() << '\n';
    for (int k = 0; k < card.size(); k++) {
        cout << card[k][0] << ' ';
    }
    cout << '\n';
}

시간 초과 (오답)

 


 

첫 앳코더..!!! 2솔 했지만.. 열심히 실력 키워서 3솔을 목표로!!

 

'Contest' 카테고리의 다른 글

[AtCoder] ABC 355 (2024-05-25)  (1) 2024.05.26
Good Bye, BOJ 2023!  (0) 2024.01.09
2023 서울대학교 프로그래밍 경시대회 (SNUPC) - Division 2  (0) 2023.09.25
Comments