-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnitk06.cpp
More file actions
36 lines (34 loc) · 728 Bytes
/
nitk06.cpp
File metadata and controls
36 lines (34 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <algorithm>
#include <bitset>
#include <string>
#include <vector>
#include <utility>
#include <list>
#include <set>
#include <map>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
// freopen("../output.txt", "w", stdout);
int test_cases, n, x;
cin >> test_cases;
while (test_cases--) {
cin >> n;
if (!n) {
cout << "NO" << endl;
continue;
}
vector <int> elements;
while (n--) {
cin >> x;
elements.push_back(x);
}
if (elements.size() > 1)
for (int i = 1; i < elements.size(); i++)
elements[i] = elements[i]-min(elements[i], elements[i-1]);
if (elements[elements.size()-1]) cout << "NO" << endl;
else cout << "YES" << endl;
}
return 0;
}