2
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/07/02

Posted at

AtCoder

AtCoder Beginner Contest 376

A - Candy Button

  • 簡単ではあるけどA問題にしては難しくない?って思ってしまった。
  • A問題でこのif文とcontinue使わせてくるかあって感じ
int main() {
    long long N,C;
    cin >> N >> C;
    vector<long long> T(N);
    for (long long i = 0; i < N; i++) {
        cin >> T[i];
    }
    long long ans = 0;
    long long tmp = 0;
    for (long long i = 0; i < N; i++) {
        if (i == 0) {
            tmp = T[i];
            ans++;
            continue;
        }
        if (T[i] - tmp >= C){
            ans++;
            tmp = T[i];
        }
    }
    cout << ans << endl;    
        
}

B - Hands on Ring (Easy)

  • 移動元から移動先へ移動するのも移動先から移動元へ移動するのも同じ移動回数であるという性質を使って場合分けの回数を減らすのが重要らしい。
2
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
2
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?