結果
| 問題 | 
                            No.1425 Yet Another Cyclic Shifts Sorting
                             | 
                    
| コンテスト | |
| ユーザー | 
                             沙耶花
                         | 
                    
| 提出日時 | 2021-03-12 21:51:39 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 591 bytes | 
| コンパイル時間 | 5,607 ms | 
| コンパイル使用メモリ | 249,552 KB | 
| 最終ジャッジ日時 | 2025-01-19 14:34:42 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 WA * 18 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |                 scanf("%d",&A[i]);
      |                 ~~~~~^~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000
int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N);
	rep(i,N){
		scanf("%d",&A[i]);
	}
	
	int cur = 0;
	int ans = Inf;
	int m = 0;
	rep(i,N-1){
		if(A[i] > A[i+1])cur++;
		m = max(m,A[i]);
	}
	m = max(m,A.back());
	if(m==A.back())ans = cur;
	
	rep(i,N){
		if(A[i]>A[(i+1)%N])cur--;
		if(A[(i+N-1)%N]>A[i])cur++;
		ans = min(ans,cur+1);
	}
	
	cout<<ans<<endl;
	
    return 0;
}
            
            
            
        
            
沙耶花