제출 #90574

#제출 시각아이디문제언어결과실행 시간메모리
90574tjrwodnjs999이상한 수열 (OJUZ10_bizarre)C++11
62 / 100
38 ms6560 KiB
#include <bits/stdc++.h>
using namespace std;
int arr[50005],n,m,cnt,sum=1e9;
map<int,bool> Map;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",arr+i);
        if(!Map[arr[i]]) Map[arr[i]]=1,cnt++;
    }
    scanf("%d",&m);
    sort(arr,arr+n);
    for(int i=0;i<n;i++){
        if(arr[i]>=cnt){
            sum=arr[i];
            break;
        }
    }
    printf("%d",m<=n?arr[m-1]:min(cnt+m-n-1,sum));
}

컴파일 시 표준 에러 (stderr) 메시지

bizarre.cpp: In function 'int main()':
bizarre.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bizarre.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",arr+i);
         ~~~~~^~~~~~~~~~~~
bizarre.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&m);
     ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...