UVa 231 - Testing the Catcher
#include <cstdio> #include <vector> #include <algorithm> #include <functional> using namespace std; typedef vector<int> vi; #define FOR(t, b, e, it) for(t::iterator it=b;it!=e;it++) int main(){ int tmp, ctr=0; vi m; scanf("%d", &tmp); while(tmp!=-1){ vi::iterator i; m.clear(); while(tmp!=-1){ i=upper_bound(m.begin(), m.end(), tmp, greater<int>()); if(i==m.end()) m.push_back(tmp); else *i=tmp; scanf("%d", &tmp); } if(ctr)printf("\n"); printf("Test #%d:\n maximum possible interceptions: %d\n",++ctr, m.size()); scanf("%d", &tmp); } return 0; }
Ideone: http://ideone.com/1H8M2E
can u explain vi::iterator i;?
ReplyDeleteThat is vector::iterator
ReplyDeleteRead about iterator here: http://www.cplusplus.com/reference/iterator/