О, наконец освободился этот слот, ну, в общем, смотри как надо было эту задачу решать:
#include <iostream>
#include <vector>
#include <set>
#define ll long long
using namespace std;
signed main() {
ll n;
cin >> n;
vector<pair<ll,ll>> a(n);
vector<ll> pref(n,0),d(n,0),ans(n,0);
set<ll> s;
for(ll i = 0; i < n; i++){
cin >> a[i].first;
a[i].second = i;
s.insert(a[i].first);
if(i == 0)
pref[i] = a[i].first;
else
pref[i] = pref[i-1] + a[i].first;
d[i] = s.size();
}
if(d[n-1] > 1 || n == 1)
ans[a[n-1].second] = 1;
for(ll i = n - 2; i >= 0; i--){
if(pref[i] > a[i + 1].first && ans[a[i+1].second] == 1 && d[i] > 1)
ans[a[i].second] = 1;
}
for(ll i = 0; i < n; i++)
cout << ans[i] << " ";
}
#include <iostream>
using namespace std;
class circle {
public:
int x, y;
double r, s;
circle()
{
x = 0;
y = 0;
r = 0;
}
circle( int a = 0, int b = 0, double c = 0 )
{
set(a, b, c);
}
void out()
{
cout << "Координаты: (" << x << ", " << y << ") Радиус: "<< r << " Площадь: " << endl;
}
void set(int a, int b, double c)
{
x = a;
y = b;
r = c;
}
void calculate() {
s = r * r * 3.14159;
}
};
class sphere : public circle {
private:
double v;
void calculate() {
s = 4 * 3.14 * r * r;
v = 3.14159 * pow(r, 3);
}
public:
sphere();
sphere() : circle(circle, double = 1.0);
sphere (int = 0, int = 0, double = 1.0) ;
void out()
{
circle::out();
cout << ", радиус: " << r << ", длина: " << ", площадь: " << s;
}
};
int main(){
setlocale(LC_ALL, "ru");
circle a(2, 15, 4);
a.out();
sphere b;
system("pause");
return 0;
}
Объяснение: пойдёт?
Pascal:
1.
var a,b:Integer;
x:Double;
begin
writeln('Введите a, b: ');
readln(a,b);
x:=a+b;
writeln(a,'+',b,'=',x);
x:=a*b;
writeln(a,'*',b,'=',x);
end.
2.
var a,b:Integer;
begin
writeln('Введите оценки за две КР: ');
readln(a,b);
if (a+b)>= 8 then writeln('Молодец!')
else writeln('Подтянись!')
end.
Python:
1.
a, b = int(input('Введите a')), int(input('Введите b'))
x = a+b
print(str(a) + '+' + str(b) + '=' + str(x))
x = a*b
print(str(a) + '*' + str(b) + '=' + str(x))
2.
a, b = int(input('Введите первую оценку')), int(input('Введите вторую оценку'))
if a+b >= 8:
print('молодец!')
else:
print('подтянись!')
N=int(input())
a=[]
sum = 0
f = 0
c = 0
for i in range(N):
l = int(input())
sum = sum + l
a.append(l)
if N == 1:
print(1)
else:
ans = []
for i in range(N-1, 0, -1):
if a[i] > a[i-1]:
if sum > a[-1] or (sum > a[i+1] and f == 1):
for k in range(c+1):
ans.append(1)
c = 0
f = 1
else:
ans.append(0)
f = 0
elif a[i] == a[i-1]:
c += 1
else:
ans.append(0)
f = 0
sum=sum-a[i]
ans = ans[::-1]
print(0)
for i in range(c):
print(0)
for i in ans:
print(i)
Объяснение:
во отве ☝️☝️☝️