結果
| 問題 |
No.116 門松列(1)
|
| コンテスト | |
| ユーザー |
HiroakiSoftware
|
| 提出日時 | 2015-01-04 23:46:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 914 bytes |
| コンパイル時間 | 108 ms |
| コンパイル使用メモリ | 23,040 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 00:56:11 |
| 合計ジャッジ時間 | 803 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf ( "%d" , &N );
| ~~~~~~^~~~~~~~~~~~~
main.cpp:14:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf ( "%d" , Data + i );
| ~~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main ( void ) {
int N;
scanf ( "%d" , &N );
int Data [ 100 ];
int SortedData [ 3 ];
for ( int i = 0; i < N; i++ ) {
scanf ( "%d" , Data + i );
}
int Count = 0;
for ( int i = 0; ( i + 2 ) < N; i++ ) {
SortedData [ 0 ] = Data [ i ];
SortedData [ 1 ] = Data [ i + 1 ];
SortedData [ 2 ] = Data [ i + 2 ];
if ( SortedData [ 0 ] == SortedData [ 1 ] )continue;
if ( SortedData [ 0 ] == SortedData [ 2 ] )continue;
if ( SortedData [ 1 ] == SortedData [ 2 ] )continue;
for ( int j = 0; j < 3; j++ ) {
for ( int k = 0; k < 2; k++ ) {
if ( SortedData [ k ] > SortedData [ k + 1 ] ) {
int buf = SortedData [ k ];
SortedData [ k ] = SortedData [ k + 1 ];
SortedData [ k + 1 ] = buf;
}
}
}
if ( ( Data [ i ] == SortedData [ 1 ] ) || ( Data [ i + 2 ] == SortedData [ 1 ] ) ) {
Count++;
}
}
printf ( "%d\n" , Count );
return 0;
}
HiroakiSoftware