結果
| 問題 | No.1438 Broken Drawers | 
| コンテスト | |
| ユーザー |  Nachia | 
| 提出日時 | 2021-03-26 21:59:28 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 57 ms / 2,000 ms | 
| コード長 | 406 bytes | 
| コンパイル時間 | 2,641 ms | 
| コンパイル使用メモリ | 194,240 KB | 
| 最終ジャッジ日時 | 2025-01-19 22:35:12 | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |   scanf("%d",&N);
      |   ~~~~~^~~~~~~~~
main.cpp:14:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |   rep(i,N){ int a; scanf("%d",&a); I[a-1]=i; }
      |                    ~~~~~^~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int N;
vector<int> I;
vector<int> F;
int main(){
  scanf("%d",&N);
  I.resize(N);
  rep(i,N){ int a; scanf("%d",&a); I[a-1]=i; }
  F.assign(N+1,0);
  int ans=0;
  rep(i,N){
    if(F[I[i]+1]) continue;
    F[I[i]]=1;
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}
            
            
            
        