結果

問題 No.1438 Broken Drawers
ユーザー yansi819
提出日時 2024-04-29 18:03:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 4,471 ms
コンパイル使用メモリ 255,436 KB
最終ジャッジ日時 2025-02-21 09:40:40
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int main() {
  int N; cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i].first;
    A[i].second = i;
  }
  vector<bool> f(N, true);
  sort(A.begin(), A.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i].second == N - 1 || f[A[i].second + 1]) {
      ans++;
      f[A[i].second] = false;
    } 
  }
  cout << ans << endl;
  return 0;
}
0