| 14271 | 2025-01-10 11:18:53 | Tunde | Maximális szorzat (50 pont) | cpp17 | Forditási hiba |
using namespace std;
int main()
{
long long n, k, b, db=0;
long long szor=1;
cin >> n >> k >> b;
int t[n];
for(int i=0; i<n; i++)
{
cin >> t[i];
if(t[i]<0)
++db;
}
if(db<b)
cout << -1;
else
{
sort(t, t+n);
long long i=0;
while(db!=b && i<k)
{
if(db%2==0)
{
if((t[db-1]+t[db-2])+(k-i)>=0)
{
t[db-2]=0;
t[db-1]=0;
i-=t[db-2];
i-=t[db-1];
db-=2;
}
else
i=k;
}
else
{
if(t[db-1]+(k-i)>=0)
{
i-=t[db-1];
t[db-1]=0;
db--;
}
}
}
if(db>b)
cout << -1;
else
{
while(i<k)
{
t[b]++;
sort(t+b, t+n);
i++;
}
for(int i=0; i<n; i++)
{
szor*=t[i];
if(szor==0)
break;
}
cout << szor%(1000000000+7);
}
}
}
open /var/local/lib/isolate/436/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:7:5: error: 'cin' was not declared in this scope
7 | cin >> n >> k >> b;
| ^~~
main.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
+++ |+#include <iostream>
1 | using namespace std;
main.cpp:16:9: error: 'cout' was not declared in this scope
16 | cout << -1;
| ^~~~
main.cpp:16:9: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
main.cpp:19:9: error: 'sort' was not declared in this scope; did you mean 'short'?
19 | sort(t, t+n);
| ^~~~
| short
main.cpp:47:13: error: 'cout' was not declared in this scope
47 | cout << -1;
| ^~~~
main.cpp:47:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
main.cpp:62:13: error: 'cout' was not declared in this scope
62 | cout << szor%(1000000000+7);
| ^~~~
main.cpp:62:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?