Submission #90575

#TimeUsernameProblemLanguageResultExecution timeMemory
90575tjrwodnjs999이상한 수열 (OJUZ10_bizarre)C++11
100 / 100
70 ms5812 KiB
#include <bits/stdc++.h> using namespace std; int arr[50005],arr2[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); arr2[i]=arr[i]; if(!Map[arr[i]]) Map[arr[i]]=1,cnt++; } scanf("%d",&m); sort(arr2,arr2+n); for(int i=0;i<n;i++){ if(arr2[i]>=cnt){ sum=arr2[i]; break; } } printf("%d",m<=n?arr[m-1]:min(cnt+m-n-1,sum)); }

Compilation message (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); arr2[i]=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...