pacixor
//GCC 7.2.0 // 1 #include <iostream> using namespace std; int main() { int n, sum; cin >> n; sum = 0; int *A = new int [n]; for (int i = 0; i < n; i++) { cin >> A[i]; sum += A[i]; } if (sum < 0) cout << "NO"; else cout << "YES";
return 0; }
//2 #include <iostream> using namespace std; int main() { int n, min, max; cin >> n; int *A = new int [n]; for (int i = 0; i < n; i++) cin >> A[i]; min = A[0]; max = A[0]; for (int i = 0; i < n; i++) { if (A[i] < min) min = A[i]; if (A[i] > max) max = A[i]; } float mean = (max + min) / 2.0; cout << mean;
return 0; }
//3 #include <iostream> using namespace std; int main() { int h = 1; int k = 1; int s; cin >> s;
while (k < s) { for (int i = 0; i < h; i++) cout << h; h++; k = k + h; }
Answers & Comments
// 1
#include <iostream>
using namespace std;
int main() {
int n, sum;
cin >> n;
sum = 0;
int *A = new int [n];
for (int i = 0; i < n; i++)
{
cin >> A[i];
sum += A[i];
}
if (sum < 0) cout << "NO";
else cout << "YES";
return 0;
}
//2
#include <iostream>
using namespace std;
int main() {
int n, min, max;
cin >> n;
int *A = new int [n];
for (int i = 0; i < n; i++)
cin >> A[i];
min = A[0]; max = A[0];
for (int i = 0; i < n; i++)
{
if (A[i] < min) min = A[i];
if (A[i] > max) max = A[i];
}
float mean = (max + min) / 2.0;
cout << mean;
return 0;
}
//3
#include <iostream>
using namespace std;
int main() {
int h = 1;
int k = 1;
int s;
cin >> s;
while (k < s) {
for (int i = 0; i < h; i++)
cout << h;
h++;
k = k + h;
}
for (int i = k - h; i < s; i++)
cout << h;
return 0;
}