結果

問題 No.365 ジェンガソート
ユーザー @abcde
提出日時 2019-06-29 22:36:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 1,253 ms
コンパイル使用メモリ 161,104 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-02 05:41:32
合計ジャッジ時間 2,743 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d", &v);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

// ロジック検討中.
#include <bits/stdc++.h>
using namespace std;

int main() {
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    vector<int> a;
    for(int i = 0; i < N; i++){
        int v;
        scanf("%d", &v);
        a.push_back(v);
    }
    
    // 2. a[0] と 比較.
    int ans = 0, cmp = 0;
    bool b = false;
    for(int i = 1; i < N; i++){
        if(a[i] < a[0]) ans++;
        if(a[i] > a[0]){
            if(a[i] > cmp) cmp = a[i];
            else           ans++, b = true;
        }
    }

    // 3. 出力.
    if(b) ans++;
    printf("%d\n", ans);
    return 0;
    
}
0