0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AtCoder Beginner Contest 463

0
Posted at

A - 16:9

問題文

16:9 = x:y

16 * y = 9 * x

ですね。

C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    int x, y;
    cin >> x >> y;

    if(9 * x == 16 * y) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
} 

B - Train Reservation

問題文

x列を固定して行をfor文で探索します。

C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    int n;
    char c;
    cin >> n >> c;
    int x = c - 'A';
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    rep(i, n){
        if(s[i][x] == 'o'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
} 

C - Tallest at the Moment

問題文

T_iをコピーしたTT_iを用意します。
TT_iをソートして前処理で任意の時間の高橋くんの身長の最大を探索します。
今回はmapで高橋くんの身長の最大を保持します。
最後にT_iをforでループして指定の時間の高橋くんの身長の最大を表示します。

C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    int n, q;
    cin >> n;
    vector<pair<int, int>> lh(n);
    set<int> st;
    rep(i, n){
        int h, l;
        cin >> h >> l;
        lh[i] = {l, h};
        st.insert(h);
    }
    sort(lh.rbegin(), lh.rend());
    cin >> q;
    vector<int> t(q), tt(q);
    map<int, int> mp;
    rep(i, q) cin >> t[i], tt[i] = t[i];
    sort(tt.begin(), tt.end());
    for(int i=0; i<q; i++){
        while(lh.back().first <= tt[i]){
            st.erase(lh.back().second);
            lh.pop_back();
        }
        mp[tt[i]] = *st.rbegin();
    }
    rep(i, q) cout << mp[t[i]] << endl;
    return 0;
} 

問題文

C++
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?