#3941
Scrieți funcția care are antetul:
long long CountSumS(vector<int> &a, int s)
Funcția va returna numărul de perechi (a[i], a[j]) cu i < j și a[i] + a[j] = s.
| Problema | CountSumS | Operații I/O |
countsums.in/countsums.out
|
|---|---|---|---|
| Limita timp | 0.4 secunde | Limita memorie |
Total: 128 MB
/
Stivă 64 MB
|
| Id soluție | #64779027 | Utilizator | |
| Fișier | countsums.cpp | Dimensiune | 717 B |
| Data încărcării | 29 Mai 2026, 22:31 | Scor/rezultat | Eroare de compilare |
countsums.cpp:4:1: error: stray ‘\`’ in program 4 | \`\`\`cpp | ^ countsums.cpp:4:2: error: stray ‘\`’ in program 4 | \`\`\`cpp | ^ countsums.cpp:4:3: error: stray ‘\`’ in program 4 | \`\`\`cpp | ^ countsums.cpp:4:4: error: ‘cpp’ does not name a type 4 | \`\`\`cpp | ^~~ countsums.cpp: In function ‘long long int CountSumS(std::vector<int>&, int)’: countsums.cpp:27:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 27 | int main() | ^~ countsums.cpp:27:9: note: remove parentheses to default-initialize a variable 27 | int main() | ^~ | -- countsums.cpp:27:9: note: or replace parentheses with braces to value-initialize a variable countsums.cpp:28:1: error: a function-definition is not allowed here before ‘{’ token 28 | { | ^ countsums.cpp:40:2: error: expected ‘}’ at end of input 40 | } | ^ countsums.cpp:23:20: note: to match this ‘{’ 23 | } else { | ^ countsums.cpp:40:2: error: expected ‘}’ at end of input 40 | } | ^ countsums.cpp:16:55: note: to match this ‘{’ 16 | if (countMap.find(s - num) != countMap.end()) { | ^ countsums.cpp:40:2: error: expected ‘}’ at end of input 40 | } | ^ countsums.cpp:15:31: note: to match this ‘{’ 15 | for (const auto& num : a) { | ^ countsums.cpp:40:2: error: expected ‘}’ at end of input 40 | } | ^ countsums.cpp:8:44: note: to match this ‘{’ 8 | long long CountSumS(vector<int> &a, int s) { | ^ countsums.cpp:40:2: warning: no return statement in function returning non-void [-Wreturn-type] 40 | } | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema CountSumS face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.