Submission #14304

#TimeUsernameProblemLanguageResultExecution timeMemory
14304pichulia이상한 수열 (OJUZ10_bizarre)C++98
100 / 100
33 ms49520 KiB
#include<stdio.h> #define M 1000000 int n, m; long long int a[3100099]; long long int s[3100000]; int main() { int i, j, k, l; scanf("%d",&n); for(i=1;i<=n;i++){scanf("%lld",&a[i]);s[a[i]+M]++;} scanf("%d",&m); int cnt=0; for(i=0;i<2*M+20;i++)if(s[i])cnt++; for(i=n+1;i<2*M+20;i++) { a[i]=cnt; s[cnt+M]++; if(s[cnt+M]==1)cnt++; } if(m<2*M+20) { printf("%lld\n",a[m]); } else { long long int p,q; p = a[i-2]; q = a[i-1]; { q+=(m-i+1)*(q-p); printf("%lld\n",q); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...