# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
164635699 |
Practice:
Andalus |
1707B
- 26
|
C++14 (GCC 6-32)
|
Accepted
|
46 ms
|
1064 KB
|
2022-07-17 19:38:50 |
2022-07-17 19:38:50 |
|
# include <bits/stdc++.h>
using namespace std;
void solve ()
{
int n, k, val;
vector <int> vec;
cin >> n;
int start = 0, nzind = 0;
for (int i = 0; i < n; i++)
{
cin >> val;
vec.push_back (val);
if (val == 0)
nzind++;
}
while (nzind < n - 1)
{
if (nzind != 0)
vec[nzind - 1] = vec[nzind];
for (int i = nzind; i < n - 1; i++)
vec[i] = vec[i + 1] - vec[i];
if (nzind > 0)
nzind--;
n--;
sort (vec.begin() + nzind, vec.begin() + n);
while (vec[nzind] == 0)
nzind++;
}
cout << vec[n - 1] << '\n';
}
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--)
solve();
}
Click to see test details