Codechef Starters 114 Division 3 (Rated) Christmas Candy Solution
Problem Link : https://www.codechef.com/problems/CHRISCANDY
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- int n ;
- cin >> n ;
- std::vector<int> a(n);
- for ( int i = 0 ; i < n ; i++){
- cin >> a[i] ;
- }
- int ans = 0 , mx = a[0] ;
- for ( int i = 1 ; i < n ; i++){
- if (a[i] > mx ){
- mx = a[i] ;
- }
- else ans++ ;
- }
- cout << ans <<'\n';
- }
- return 0 ;
- }
No comments