Sunday, December 29, 2013

codechef CARVANS - "carvans" solution

codechef CARVANS - "carvans": http://www.codechef.com/problems/CARVANS

codechef CARVANS - "carvans" solution: http://ideone.com/6jhSPA

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
// your code goes here
int t, n, k, temp, count;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
count=0;
for(int i=0; i<n; i++) {
scanf("%d", &k); if(i==0) temp=k;
if(k<=temp) {
temp=k; count++;
}
}
cout<<count<<endl;
}
return 0;
}

No comments:

Post a Comment