File tree 5 files changed +46
-0
lines changed
5 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ // works if you are given the length of the array
5
+ int main () {
6
+ /*
7
+ run for loop with value of n, the cin into
8
+ v[i]. This works because C++ interprets spaces
9
+ as separators between inputs, just like it
10
+ does for newlines.
11
+ */
12
+ int n; cin >> n;
13
+ vector<int > v (n);
14
+ for (int i = 0 ; i < n; i++) cin >> v[i];
15
+
16
+ // testing
17
+ for (int i : v) cout << i << " -> " ;
18
+ return 0 ;
19
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ int main () {
5
+ int t; cin >> t;
6
+
7
+ while (t--) {
8
+ int n; cin >> n;
9
+ vector<int > v (n);
10
+ for (int i = 0 ; i < n; i++) cin >> v[i];
11
+ bool not_sorted = false ;
12
+ for (int i = 0 ; i < n-1 ; i++)
13
+ if (v[i] > v[i+1 ]) not_sorted = true ;
14
+
15
+ if (not_sorted) cout << " YES\n " ;
16
+ else cout << " NO\n " ;
17
+ }
18
+ return 0 ;
19
+ }
Original file line number Diff line number Diff line change
1
+ for i in range (int (input ())):
2
+ n = int (input ())
3
+ a = list (map (int , input ().split ()))
4
+ if a != sorted (a ): print ("YES" )
5
+ else : print ("NO" )
Original file line number Diff line number Diff line change @@ -19,5 +19,7 @@ int main() {
19
19
if (i != v.size () - 1 )
20
20
cout << v[i] << ' +' ;
21
21
else cout << v[i];
22
+
23
+ return 0 ;
22
24
23
25
}
Original file line number Diff line number Diff line change @@ -10,4 +10,5 @@ int main() {
10
10
cout << 1 ;
11
11
else if (x % 5 == 0 ) cout << x / 5 ;
12
12
else cout << x / 5 + 1 ;
13
+ return 0 ;
13
14
}
You can’t perform that action at this time.
0 commit comments