結果
問題 | No.1438 Broken Drawers |
ユーザー |
|
提出日時 | 2021-03-26 21:54:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 1,141 bytes |
コンパイル時間 | 7,123 ms |
コンパイル使用メモリ | 253,212 KB |
最終ジャッジ日時 | 2025-01-19 22:30:24 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> typedef unsigned long long ULLONG; typedef long long LLONG; static const LLONG MOD_NUM = 1000000007LL; //998244353LL; template<class _T> static void get(_T& a) { std::cin >> a; } template<class _T> static void get(_T& a, _T& b) { std::cin >> a >> b; } template<class _T> static void get(_T& a, _T& b, _T& c) { std::cin >> a >> b >> c; } template <class _T> static _T tp_abs(_T a) { if (a < (_T)0) { a *= (_T)-1; } return a; } static void task(); int main() { task(); fflush(stdout); return 0; } static void task() { int N; get(N); std::vector<std::pair<int, int>> ai(N); for (int i = 0; i < N; i++) { get(ai[i].second); ai[i].first = i + 1; } auto cmp = [](const std::pair<int, int>& a, const std::pair<int, int>& b) { return a.second < b.second; }; std::sort(ai.begin(), ai.end(), cmp); std::vector<int> ok(N + 1, 1); int now = -1; int len = 0; for (int i = 0; i < N; i++) { if (!ok[ai[i].first]) continue; if (now < ai[i].second) { now = ai[i].second; ok[ai[i].first] = 0; ok[ai[i].first - 1] = 0; len++; } } printf("%d\n", len); }