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 生活109日目

Posted at

前回

#109日目
今日は、灰色を2問と茶色2問を解きました。

|問題|難易度|自力で解けた|かかった時間|
|:-:|:-:|:-:|---|---|
|AGC041|A|✕|34分14秒|
|ABC095|C|◯|10分46秒|
|ARC099|C|✕|135分16秒|
|ABC085|C|◯|16分30秒|

##AGC041_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(){
    ll n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0)cout << (b-a)/2 << endl;
    else cout << min(a-1,n-b) + 1 + (b-a-1)/2 << endl;
}

解くのにかかった時間:34分14秒
感想:AGCの灰色も素早く解けるようにしていきたい。

##ABC095_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 a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll r = max(x,y);
    ll ans = 0;
    if((a+b) > 2*c){
        int z = min(x,y);
        ans += z*2*c;
        x -= z;
        y -= z;
    }
    cout << min((ans + x*a + y*b),c*2*r) << endl;
}

解くのにかかった時間:10分46秒

##ARC099_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,k;
    cin >> n >> k;
    cout << (n + k - 3)/(k - 1) << endl;
}

解くのにかかった時間:135分16秒
感想:まさかここまで簡略できるとは思わなかった。

##ABC085_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(){
    ll n,y;
    cin >> n >> y;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= (n-i);j++){
            int k = n - i - j;
            if((i*10000 + j*5000 + k*1000) == y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

解くのにかかった時間:16分30秒

###最後に
ABC以外の灰色diffも解けるようにしておきたい。

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?