1838A - Blackboard List - CodeForces Solution


math

Please click on ads to support us..

C++ Code:

// Problem: A. Blackboard List
// Contest: Codeforces - Codeforces Round 877 (Div. 2)
// URL: https://codeforces.com/contest/1838/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

//  !! Har Har Mahadev !!
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update> order_of_key(k) , find_by_order(k)
#define setbits(x) __builtin_popcountll(x)
#define fill(a, b) memset(a, b, sizeof(a))
#define f(i, x) for (int i = 0; i < x; i++)
#define fn(i, x) for (int i = 0; i <= x; i++)
#define fab(i, a, b) for (int i = a; i <= b; i++)
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define inf 1e18
#define mod 1000000007
#define pi 3.14159265359
#define sqrt sqrtl
ll gcd(ll a, ll b) {
  if (b > a) {
    return gcd(b, a);
  }
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

ll expo(ll a, ll b, ll m) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % m;
    a = (a * a) % m;
    b = b >> 1;
  }
  return res % m;
}
int nCr(int n, int r) {
  if (n < r) return 0;
  if (r > n - r) r = n - r;
  ll ans = 1;
  ll i;
  for (i = 1; i <= r; i++) {
    ans = (ans * (n - r + i));
    ans /= i;
  }
  return ans;
}
void solve() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  f(i, n) cin >> v[i];
  sort(all(v));
  if (v[0] < 0)
    cout << v[0] << endl;
  else
    cout << v[n - 1] << endl;
  return;
}
int main() {
  fastio;
  ll t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}


Comments

Submit
0 Comments
More Questions

HILLSEQ Hill Sequence
MAXBRIDGE Maximise the bridges
WLDRPL Wildcard Replacement
1221. Split a String in Balanced Strings
1002. Find Common Characters
1602A - Two Subsequences
1555A - PizzaForces
1607B - Odd Grasshopper
1084A - The Fair Nut and Elevator
1440B - Sum of Medians
1032A - Kitchen Utensils
1501B - Napoleon Cake
1584B - Coloring Rectangles
1562B - Scenes From a Memory
1521A - Nastia and Nearly Good Numbers
208. Implement Trie
1605B - Reverse Sort
1607C - Minimum Extraction
1604B - XOR Specia-LIS-t
1606B - Update Files
1598B - Groups
1602B - Divine Array
1594B - Special Numbers
1614A - Divan and a Store
2085. Count Common Words With One Occurrence
2089. Find Target Indices After Sorting Array
2090. K Radius Subarray Averages
2091. Removing Minimum and Maximum From Array
6. Zigzag Conversion
1612B - Special Permutation