#3699
third
Aveți la dispoziție un șir a
1
, a
2
, …, a
n
de numere naturale și k
un număr natural. Pentru fiecare secvență de lungime k
din vector trebuie să determinăm pe third, cea de-a treia cea mai mică valoare. De exemplu, secvența 3,6,1,3,7,4
are ca third pe 3
, iar secvența 7,7,7,2,2,2,6
are ca third pe 2
. Calculați suma valorilor third pentru toate secvențele de lungime k
din șir.
Folclorul informatic
Problema | third | Operații I/O |
third.in /third.out
|
---|---|---|---|
Limita timp | 0.2 secunde | Limita memorie |
Total: 128 MB
/
Stivă 8 MB
|
Id soluție | #51575806 | Utilizator | |
Fișier | third.c | Dimensiune | 3.38 KB |
Data încărcării | 14 Iulie 2024, 19:46 | Scor / rezultat | Eroare de compilare |
third.c:1:5: warning: missing terminating ' character [enabled by default] Here's a more efficient version of your code, focusing on minimizing unnecessary operations and memory allocations: ^ third.c:1:1: error: missing terminating ' character Here's a more efficient version of your code, focusing on minimizing unnecessary operations and memory allocations: ^ third.c:3:1: error: stray '\`' in program \`\`\`c ^ third.c:3:1: error: stray '\`' in program third.c:3:1: error: stray '\`' in program third.c:1:1: error: unknown type name 'Here' Here's a more efficient version of your code, focusing on minimizing unnecessary operations and memory allocations: ^ In file included from /usr/include/stdio.h:33:0, from third.c:4: /usr/lib/gcc/i686-linux-gnu/4.8/include/stddef.h:212:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef' typedef __SIZE_TYPE__ size_t; ^ In file included from /usr/include/stdio.h:74:0, from third.c:4: /usr/include/libio.h:306:3: error: unknown type name 'size_t' size_t __pad5; ^ /usr/include/libio.h:310:67: error: 'size_t' undeclared here (not in a function) char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; ^ /usr/include/libio.h:338:62: error: expected declaration specifiers or '...' before 'size_t' typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes); ^ /usr/include/libio.h:347:6: error: expected declaration specifiers or '...' before 'size_t' size_t __n); ^ /usr/include/libio.h:469:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_IO_sgetn' extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t); ^ In file included from third.c:4:0: /usr/include/stdio.h:337:20: error: expected declaration specifiers or '...' before 'size_t' int __modes, size_t __n) __THROW; ^ /usr/include/stdio.h:386:44: error: expected declaration specifiers or '...' before 'size_t' extern int snprintf (char *__restrict __s, size_t __maxlen, ^ /usr/include/stdio.h:390:45: error: expected declaration specifiers or '...' before 'size_t' extern int vsnprintf (char *__restrict __s, size_t __maxlen, ^ /usr/include/stdio.h:709:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fread' extern size_t fread (void *__restrict __ptr, size_t __size, ^ /usr/include/stdio.h:715:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fwrite' extern size_t fwrite (const void *__restrict __ptr, size_t __size, ^ In file included from /usr/include/stdio.h:937:0, from third.c:4: /usr/include/i386-linux-gnu/bits/stdio2.h:23:61: error: expected declaration specifiers or '...' before 'size_t' extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen, ^ /usr/include/i386-linux-gnu/bits/stdio2.h:25:62: error: expected declaration specifiers or '...' before 'size_t' extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen, ^ /usr/include/i386-linux-gnu/bits/stdio2.h:52:50: error: expected declaration specifiers or '...' before 'size_t' extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag, ^ /usr/include/i386-linux-gnu/bits/stdio2.h:53:7: error: expected declaration specifiers or '...' before 'size_t' size_t __slen, const char *__restrict __format, ^ /usr/include/i386-linux-gnu/bits/stdio2.h:55:51: error: expected declaration specifiers or '...' before 'size_t' extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, ^ /usr/include/i386-linux-gnu/bits/stdio2.h:56:8: error: expected declaration specifiers or '...' before 'size_t' size_t __slen, const char *__restrict __format, ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/stdio2.h:61:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (snprintf (char *__restrict __s, size_t __n, ^ /usr/include/i386-linux-gnu/bits/stdio2.h:74:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (vsnprintf (char *__restrict __s, size_t __n, ^ In file included from /usr/include/stdio.h:937:0, from third.c:4: /usr/include/i386-linux-gnu/bits/stdio2.h:227:39: error: expected declaration specifiers or '...' before 'size_t' extern char *__gets_chk (char *__str, size_t) __wur; ^ /usr/include/i386-linux-gnu/bits/stdio2.h:241:49: error: expected declaration specifiers or '...' before 'size_t' extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n, ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/stdio2.h:246:14: error: expected declaration specifiers or '...' before 'size_t' extern char *__REDIRECT (__fgets_chk_warn, ^ In file included from /usr/include/stdio.h:937:0, from third.c:4: /usr/include/i386-linux-gnu/bits/stdio2.h: In function 'fgets': /usr/include/i386-linux-gnu/bits/stdio2.h:260:20: error: expected ')' before '__n' if ((size_t) __n > __bos (__s)) ^ /usr/include/i386-linux-gnu/bits/stdio2.h: At top level: /usr/include/i386-linux-gnu/bits/stdio2.h:266:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__fread_chk' extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen, ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/stdio2.h:269:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__fread_alias' extern size_t __REDIRECT (__fread_alias, ^ /usr/include/i386-linux-gnu/bits/stdio2.h:273:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__fread_chk_warn' extern size_t __REDIRECT (__fread_chk_warn, ^ In file included from /usr/include/stdio.h:937:0, from third.c:4: /usr/include/i386-linux-gnu/bits/stdio2.h:282:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fread' fread (void *__restrict __ptr, size_t __size, size_t __n, ^ In file included from third.c:5:0: /usr/include/stdlib.h:139:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__ctype_get_mb_cur_max' extern size_t __ctype_get_mb_cur_max (void) __THROW __wur; ^ /usr/include/stdlib.h:466:22: error: expected declaration specifiers or '...' before 'size_t' extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur; ^ /usr/include/stdlib.h:468:22: error: expected declaration specifiers or '...' before 'size_t' extern void *calloc (size_t __nmemb, size_t __size) ^ /usr/include/stdlib.h:468:38: error: expected declaration specifiers or '...' before 'size_t' extern void *calloc (size_t __nmemb, size_t __size) ^ /usr/include/stdlib.h:480:36: error: expected declaration specifiers or '...' before 'size_t' extern void *realloc (void *__ptr, size_t __size) ^ /usr/include/stdlib.h:756:9: error: expected declaration specifiers or '...' before 'size_t' size_t __nmemb, size_t __size, __compar_fn_t __compar) ^ /usr/include/stdlib.h:756:25: error: expected declaration specifiers or '...' before 'size_t' size_t __nmemb, size_t __size, __compar_fn_t __compar) ^ In file included from /usr/include/stdlib.h:760:0, from third.c:5: /usr/include/i386-linux-gnu/bits/stdlib-bsearch.h:20:49: error: expected declaration specifiers or '...' before 'size_t' bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, ^ /usr/include/i386-linux-gnu/bits/stdlib-bsearch.h:20:65: error: expected declaration specifiers or '...' before 'size_t' bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, ^ In file included from third.c:5:0: /usr/include/stdlib.h:765:34: error: expected declaration specifiers or '...' before 'size_t' extern void qsort (void *__base, size_t __nmemb, size_t __size, ^ /usr/include/stdlib.h:765:50: error: expected declaration specifiers or '...' before 'size_t' extern void qsort (void *__base, size_t __nmemb, size_t __size, ^ /usr/include/stdlib.h:863:36: error: expected declaration specifiers or '...' before 'size_t' extern int mblen (const char *__s, size_t __n) __THROW; ^ /usr/include/stdlib.h:867:34: error: expected declaration specifiers or '...' before 'size_t' const char *__restrict __s, size_t __n) __THROW; ^ /usr/include/stdlib.h:874:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mbstowcs' extern size_t mbstowcs (wchar_t *__restrict __pwcs, ^ /usr/include/stdlib.h:877:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wcstombs' extern size_t wcstombs (char *__restrict __s, ^ In file included from /usr/include/stdlib.h:959:0, from third.c:5: /usr/include/i386-linux-gnu/bits/stdlib.h:25:9: error: expected declaration specifiers or '...' before 'size_t' size_t __resolvedlen) __THROW __wur; ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/stdlib.h:29:14: error: expected declaration specifiers or '...' before 'size_t' extern char *__REDIRECT_NTH (__realpath_chk_warn, ^ In file included from /usr/include/stdlib.h:959:0, from third.c:5: /usr/include/i386-linux-gnu/bits/stdlib.h:52:52: error: expected declaration specifiers or '...' before 'size_t' extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen, ^ /usr/include/i386-linux-gnu/bits/stdlib.h:53:8: error: expected declaration specifiers or '...' before 'size_t' size_t __nreal) __THROW __nonnull ((2)); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/stdlib.h:54:12: error: expected declaration specifiers or '...' before 'size_t' extern int __REDIRECT_NTH (__ptsname_r_alias, (int __fd, char *__buf, ^ /usr/include/i386-linux-gnu/bits/stdlib.h:57:12: error: expected declaration specifiers or '...' before 'size_t' extern int __REDIRECT_NTH (__ptsname_r_chk_warn, ^ /usr/include/i386-linux-gnu/bits/stdlib.h:57:12: error: expected declaration specifiers or '...' before 'size_t' extern int __REDIRECT_NTH (__ptsname_r_chk_warn, ^ /usr/include/i386-linux-gnu/bits/stdlib.h:64:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (ptsname_r (int __fd, char *__buf, size_t __buflen)) ^ In file included from /usr/include/stdlib.h:959:0, from third.c:5: /usr/include/i386-linux-gnu/bits/stdlib.h:77:54: error: expected declaration specifiers or '...' before 'size_t' extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen) ^ /usr/include/i386-linux-gnu/bits/stdlib.h:98:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__mbstowcs_chk' extern size_t __mbstowcs_chk (wchar_t *__restrict __dst, ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/stdlib.h:101:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__mbstowcs_alias' extern size_t __REDIRECT_NTH (__mbstowcs_alias, ^ /usr/include/i386-linux-gnu/bits/stdlib.h:105:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__mbstowcs_chk_warn' extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn, ^ /usr/include/i386-linux-gnu/bits/stdlib.h:113:1: error: expected ',' or ';' before 'mbstowcs' __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src, ^ In file included from /usr/include/stdlib.h:959:0, from third.c:5: /usr/include/i386-linux-gnu/bits/stdlib.h:130:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__wcstombs_chk' extern size_t __wcstombs_chk (char *__restrict __dst, ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/stdlib.h:133:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__wcstombs_alias' extern size_t __REDIRECT_NTH (__wcstombs_alias, ^ /usr/include/i386-linux-gnu/bits/stdlib.h:137:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__wcstombs_chk_warn' extern size_t __REDIRECT_NTH (__wcstombs_chk_warn, ^ /usr/include/i386-linux-gnu/bits/stdlib.h:144:1: error: expected ',' or ';' before 'wcstombs' __NTH (wcstombs (char *__restrict __dst, const wchar_t *__restrict __src, ^ In file included from third.c:6:0: /usr/include/string.h:47:8: error: expected declaration specifiers or '...' before 'size_t' size_t __n) __THROW __nonnull ((1, 2)); ^ /usr/include/string.h:50:56: error: expected declaration specifiers or '...' before 'size_t' extern void *memmove (void *__dest, const void *__src, size_t __n) ^ /usr/include/string.h:66:42: error: expected declaration specifiers or '...' before 'size_t' extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); ^ /usr/include/string.h:69:56: error: expected declaration specifiers or '...' before 'size_t' extern int memcmp (const void *__s1, const void *__s2, size_t __n) ^ /usr/include/string.h:96:48: error: expected declaration specifiers or '...' before 'size_t' extern void *memchr (const void *__s, int __c, size_t __n) ^ /usr/include/string.h:133:39: error: expected declaration specifiers or '...' before 'size_t' const char *__restrict __src, size_t __n) ^ /usr/include/string.h:141:9: error: expected declaration specifiers or '...' before 'size_t' size_t __n) __THROW __nonnull ((1, 2)); ^ /usr/include/string.h:147:57: error: expected declaration specifiers or '...' before 'size_t' extern int strncmp (const char *__s1, const char *__s2, size_t __n) ^ /usr/include/string.h:154:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'strxfrm' extern size_t strxfrm (char *__restrict __dest, ^ /usr/include/string.h:285:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'strcspn' extern size_t strcspn (const char *__s, const char *__reject) ^ /usr/include/string.h:289:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'strspn' extern size_t strspn (const char *__s, const char *__accept) ^ /usr/include/string.h:399:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'strlen' extern size_t strlen (const char *__s) ^ /usr/include/string.h:451:33: error: expected declaration specifiers or '...' before 'size_t' extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1)); ^ In file included from /usr/include/string.h:635:0, from third.c:6: /usr/include/i386-linux-gnu/bits/string2.h:945:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strcspn_c1' __STRING_INLINE size_t __strcspn_c1 (const char *__s, int __reject); ^ /usr/include/i386-linux-gnu/bits/string2.h:947:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strcspn_c1' __strcspn_c1 (const char *__s, int __reject) ^ /usr/include/i386-linux-gnu/bits/string2.h:955:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strcspn_c2' __STRING_INLINE size_t __strcspn_c2 (const char *__s, int __reject1, ^ /usr/include/i386-linux-gnu/bits/string2.h:958:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strcspn_c2' __strcspn_c2 (const char *__s, int __reject1, int __reject2) ^ /usr/include/i386-linux-gnu/bits/string2.h:967:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strcspn_c3' __STRING_INLINE size_t __strcspn_c3 (const char *__s, int __reject1, ^ /usr/include/i386-linux-gnu/bits/string2.h:970:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strcspn_c3' __strcspn_c3 (const char *__s, int __reject1, int __reject2, ^ /usr/include/i386-linux-gnu/bits/string2.h:1021:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strspn_c1' __STRING_INLINE size_t __strspn_c1 (const char *__s, int __accept); ^ /usr/include/i386-linux-gnu/bits/string2.h:1023:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strspn_c1' __strspn_c1 (const char *__s, int __accept) ^ /usr/include/i386-linux-gnu/bits/string2.h:1032:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strspn_c2' __STRING_INLINE size_t __strspn_c2 (const char *__s, int __accept1, ^ /usr/include/i386-linux-gnu/bits/string2.h:1035:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strspn_c2' __strspn_c2 (const char *__s, int __accept1, int __accept2) ^ /usr/include/i386-linux-gnu/bits/string2.h:1044:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strspn_c3' __STRING_INLINE size_t __strspn_c3 (const char *__s, int __accept1, ^ /usr/include/i386-linux-gnu/bits/string2.h:1047:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__strspn_c3' __strspn_c3 (const char *__s, int __accept1, int __accept2, int __accept3) ^ /usr/include/i386-linux-gnu/bits/string2.h: In function '__strpbrk_c2': /usr/include/i386-linux-gnu/bits/string2.h:1105:50: error: expected ';' before '__s' return *__s == '\0' ? NULL : (char *) (size_t) __s; ^ /usr/include/i386-linux-gnu/bits/string2.h: In function '__strpbrk_c3': /usr/include/i386-linux-gnu/bits/string2.h:1117:50: error: expected ';' before '__s' return *__s == '\0' ? NULL : (char *) (size_t) __s; ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/string3.h: At top level: /usr/include/i386-linux-gnu/bits/string3.h:48:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (memcpy (void *__restrict __dest, const void *__restrict __src, ^ /usr/include/i386-linux-gnu/bits/string3.h:55:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (memmove (void *__dest, const void *__src, size_t __len)) ^ /usr/include/i386-linux-gnu/bits/string3.h:76:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (memset (void *__dest, int __ch, size_t __len)) ^ /usr/include/i386-linux-gnu/bits/string3.h:117:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (strncpy (char *__restrict __dest, const char *__restrict __src, ^ In file included from /usr/include/string.h:640:0, from third.c:6: /usr/include/i386-linux-gnu/bits/string3.h:124:62: error: expected declaration specifiers or '...' before 'size_t' extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n, ^ /usr/include/i386-linux-gnu/bits/string3.h:125:8: error: expected declaration specifiers or '...' before 'size_t' size_t __destlen) __THROW; ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from third.c:4: /usr/include/i386-linux-gnu/bits/string3.h:126:14: error: expected declaration specifiers or '...' before 'size_t' extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src, ^ /usr/include/i386-linux-gnu/bits/string3.h:130:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (stpncpy (char *__dest, const char *__src, size_t __n)) ^ /usr/include/i386-linux-gnu/bits/string3.h:147:1: error: expected declaration specifiers or '...' before 'size_t' __NTH (strncat (char *__restrict __dest, const char *__restrict __src, ^ third.c: In function 'AlocaHeap': third.c:19:5: warning: implicit declaration of function 'malloc' [-Wimplicit-function-declaration] THeap* H = (THeap*)malloc(sizeof(THeap)); ^ third.c:19:24: warning: incompatible implicit declaration of built-in function 'malloc' [enabled by default] THeap* H = (THeap*)malloc(sizeof(THeap)); ^ third.c: In function 'main': third.c:129:20: warning: incompatible implicit declaration of built-in function 'malloc' [enabled by default] int* v = (int*)malloc(sizeof(int) * n); ^ third.c: At top level: third.c:153:1: error: stray '\`' in program \`\`\` ^ third.c:153:1: error: stray '\`' in program third.c:153:1: error: stray '\`' in program third.c: In function 'main': third.c:127:11: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf(in, "%d %d", &n, &k); ^ third.c:139:15: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf(in, "%d", &v[i]); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema third face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.