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?

More than 3 years have passed since last update.

AtCoder 生活103日目

Posted at

前回

#103日目
今日はC問題一問とABC185に参加してきました。

スクリーンショット 2020-12-13 22.45.56.png

##ABC185

###A


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min({a,b,c,d}) << endl;
}

###B


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    int n,m,t;
    cin >> n >> m >> t;
    int s = n;
    vector<pii> d(m+1);
    d[0].second = 0;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        d[i+1].first = a;
        d[i+1].second = b;
    }
    rep(i,m){
        n -= (d[i+1].first - d[i].second);
        if(n <= 0){
            cout << "No" << endl;
            return 0;
        }
        n = min(s,(n + d[i+1].second - d[i+1].first));
    }
    n -= t - d[m].second;
    if(n <= 0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

##ABC135_C


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i,(n+1)) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans = 0LL;
    rep(i,n){
        ans += min(a[i],b[i]);
        b[i] = max((b[i] - a[i]),0LL);
        ans += min(a[i+1],b[i]);
        a[i+1] = max((a[i+1] - b[i]),0LL);
    }
    cout << ans << endl;
}

解くのにかかった時間:9分17秒

###最後に
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?