1
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?

競プロ日記#25/04/17

Posted at

AtCoder

ABC160_A-Coffee

  • 特になし
int main() {
    string S;
    cin >> S;

    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

ABC160_B-Golden Coins

  • 特になし
int main() {
    long long X;
    cin >> X;

    long long ans = 0;
    int thousand = 0;
    int five = 0;
    thousand = X / 500;
    five = (X % 500) / 5;
    
    cout << thousand * 1000 + five * 5 << endl;
}

ABC160_C-Traveling Salesman around Lake

  • 結局最短ということはどこかからスタートした上でその隣まで一周する。(逆走するパターンなどはあり得ない)
  • そう考えると全部の家を通らなきゃいけない以上は通らない家と家の間は一つしかない→その間が最大となるような経路を探せばいい
int main() {
    int K,N;
    cin >> K >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<int> B(N);
    for (int i = 1; i <= N; i++) {
        
        B[i] = A[i] - A[i-1];
        if (i == N){
            B[0] = K - A[i-1] + A[0];
        }
    
    }

    cout << K - *max_element(B.begin(), B.end()) << endl;

}
  • A1から隣の家との距離を配列B1,B2,...Bn-1というように入れていく。最後にA1とAn-1との間をB0に入れる。
    後はK - *max_element(B.begin(), B.end())で答えを求めるだけ

accの自動提出ができなくなった...。

公式のポスト
せっかく環境構築したぜ!っていう矢先だったのでとても悲しです。自動テストまではできるみたい...。
提出までやれる方法知ってるよって方は是非教えてくださいませ

1
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
1
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?