int main(void) { int i, j; scanf("%d", &N); //input N; for(i=0; i<N; i++) { scanf("%d %d", &input1, &input2); if(input1 >= input2) { paper[i].saero = input1; paper[i].garo = input2; } else { paper[i].saero = input2; paper[i].garo = input1; } paper[i].saero_ = (double)paper[i].saero + ((double)paper[i].garo / ((double)paper[i].saero + 1) ); //paper[i].saero_!!! //[0]번에 큰 거, [1]번에 작은게 들어간다. } //for i quick(paper, N); //input /* printf("*****\n"); for(i=0; i<N; i++) { printf("%d %d\n", paper[i].saero, paper[i].garo); } */ lis(); /* for(i=0; i<N; i++) { printf("%d ", LIS[i]); } printf("\n"); */ for(i=0; i<N; i++) { if(result < LIS[i]) { result = LIS[i]; } } printf("%d\n", result); return 0; }
void runAllTests(int argc, char const *argv[]) { cute::suite s { }; //My tests s.push_back(CUTE(test_create_dyArray_no_args)); s.push_back(CUTE(test_create_dyArray_init_list)); s.push_back(CUTE(test_create_dyArray_eql_val)); s.push_back(CUTE(test_create_dyArray_istr_iter)); s.push_back(CUTE(test_create_dynArray_iter)); s.push_back(CUTE(test_at_func)); s.push_back(CUTE(test_at_func_lval)); s.push_back(CUTE(test_at_func_const)); s.push_back(CUTE(test_at_func_neg_index)); s.push_back(CUTE(test_oper_sqr_brac_lval)); s.push_back(CUTE(test_oper_sqr_brac_neg_index)); s.push_back(CUTE(test_oper_sqr_brac_const)); s.push_back(CUTE(test_func_front)); s.push_back(CUTE(test_func_front_lval)); s.push_back(CUTE(test_func_front_const)); s.push_back(CUTE(test_func_back)); s.push_back(CUTE(test_func_back_lval)); s.push_back(CUTE(test_func_back_const)); s.push_back(CUTE(test_func_capacity)); s.push_back(CUTE(test_func_clear)); s.push_back(CUTE(test_func_push_back)); s.push_back(CUTE(test_func_pop_back)); s.push_back(CUTE(test_func_resize_bigger)); s.push_back(CUTE(test_func_resize_smaller)); s.push_back(CUTE(test_func_resize_values)); s.push_back(CUTE(test_rand_acc_iter)); s.push_back(CUTE(test_rand_acc_iter_const)); s.push_back(CUTE(test_const_rand_acc_iter_const)); s.push_back(CUTE(test_rev_iter)); s.push_back(CUTE(test_rev_iter_const)); s.push_back(CUTE(test_const_rev_iter_const)); s.push_back(CUTE(test_func_erase)); s.push_back(CUTE(test_func_erase_cont_iter)); s.push_back(CUTE(test_func_erase_two_iter)); s.push_back(CUTE(test_func_erase_two_const_iter)); s.push_back(CUTE(test_make_dynArray)); cute::xml_file_opener xmlfile(argc, argv); cute::xml_listener<cute::ide_listener<> > lis(xmlfile.out); cute::makeRunner(lis, argc, argv)(s, "AllTests"); }
void runAllTests(int argc, char const *argv[]){ cute::suite s; s.push_back(CUTE(test_empty)); s.push_back(CUTE(test_not_empty)); s.push_back(CUTE(test_single_insert_front)); s.push_back(CUTE(test_latest_insert_front)); s.push_back(CUTE(test_multiple_insert_latest_front)); s.push_back(CUTE(test_begin_end_equal_with_empty_list)); s.push_back(CUTE(test_begin_end_unequal_with_element_in_list)); s.push_back(CUTE(test_begin)); s.push_back(CUTE(test_iterator)); s.push_back(CUTE(test_asVector)); s.push_back(CUTE(test_range_inserter)); s.push_back(CUTE(test_range_constructor)); cute::xml_file_opener xmlfile(argc,argv); cute::xml_listener<cute::ide_listener<> > lis(xmlfile.out); cute::makeRunner(lis,argc,argv)(s, "AllTests"); }
int main() { int a[M],n,i; while(1) { scanf("%d",&n); if(!n) break; for(i=0;i<n;++i) scanf("%d",a+i); printf("%d\n",n-lis(a,n)); } return 0; }
void runAllTests(int argc, char const *argv[]){ cute::suite s; //TODO add your test here s.push_back(CUTE(thisIsATest)); s.push_back(CUTE(createLightController)); s.push_back(CUTE(RememberTheLastLightIdControlled)); s.push_back(CUTE(createFakeTimeController)); s.push_back(CUTE(setFakeTimeController)); s.push_back(CUTE(ScheduleOnEverydayItsTime)); s.push_back(CUTE(ScheduleOffEverydayItsTime)); s.push_back(CUTE(ScheduleTuesdayButItsMonday)); s.push_back(CUTE(ScheduleTuesdayAndItsTuesday)); s.push_back(CUTE(ScheduleWeekEndItsFriday)); s.push_back(CUTE(ScheduleWeekEndItsSaturday)); cute::xml_file_opener xmlfile(argc,argv); cute::xml_listener<cute::ide_listener<> > lis(xmlfile.out); cute::makeRunner(lis,argc,argv)(s, "AllTests"); }
//Longest increasing subsequence including a[p] int lis(int p){ int i,maxt=1; if(p==0) return 1; if(p<0 || p>n-1) return 0; for(i=p-1;i>=0;i--){ if(a[i]<a[p]) maxt=max(maxt,1+lis(i)); } return maxt; }
void runAllTests(int argc, char const *argv[]){ cute::suite s; //TODO add your test here s.push_back(CUTE(testDefaultCtor)); s.push_back(CUTE(testValueCtor)); s.push_back(CUTE(testValueCtorWithLargeInput)); s.push_back(CUTE(testAddition)); s.push_back(CUTE(testAdditionWrap)); s.push_back(CUTE(testOutputOperator)); s.push_back(CUTE(testMultiplication)); s.push_back(CUTE(testAdditionWithInt)); s.push_back(CUTE(testAssignmentBackToInt)); s.push_back(CUTE(testAdditionWithIntExplicitCtor)); s.push_back(CUTE(testAddAssignWithInteger)); s.push_back(CUTE(testAddWithInteger)); cute::xml_file_opener xmlfile(argc,argv); cute::xml_listener<cute::ide_listener<> > lis(xmlfile.out); cute::makeRunner(lis,argc,argv)(s, "AllTests"); }
int lis(int idx) { int temp; int& ret = cache[idx]; if (ret != -1) return ret; ret = 1; for (int next = idx + 1; next < N; next++) { if (num[idx] < num[next]) { temp = 1 + lis(next); printf("%d,%d = %d\n", idx, next, temp); if (temp > ret) ret = temp; } } return ret; }
int lengthOfLIS(vector<int>& nums) { if (nums.empty()) return 0; int n = nums.size(); vector<int>lis(n, 0); int ans = INT_MIN; for (int j = 0; j < n; j++) { lis[j] = 1; for (int i = 0; i < j; i++) { if (nums[j] > nums[i]) { lis[j] = std::max(lis[j], lis[i]+1); } } } for (int i = 0; i < n; i++) { if (lis[i] > ans) ans = lis[i]; } return ans; }
void updateImmediate(vm::System* s, void* dst, int32_t src, unsigned size, bool address) { switch (size) { case 4: { int32_t* p = static_cast<int32_t*>(dst); int r = (vm::targetV4(p[1]) >> 21) & 31; if (address) { p[0] = vm::targetV4(lis(r, ha16(src))); p[1] |= vm::targetV4(src & 0xFFFF); } else { p[0] = vm::targetV4(lis(r, src >> 16)); p[1] = vm::targetV4(ori(r, r, src)); } } break; default: abort(s); } }
void runAllTests(int argc, char const *argv[]){ cute::suite s; s.push_back(CUTE(shouldAddTwoPositiveNumbers)); s.push_back(CUTE(shouldAddTwoNegativeNumbers)); s.push_back(CUTE(shouldAddTwoNumbers)); s.push_back(CUTE(shouldSubstractTwoNumbers)); s.push_back(CUTE(shouldSubstractTwoNegativeNumbers)); s.push_back(CUTE(shouldSubstractTwoPostiveNumbers)); s.push_back(CUTE(shouldDivideNonZeroNumber)); s.push_back(CUTE(shouldDivideNonZeroNegativeNumber)); s.push_back(CUTE(shouldDivideByZero)); s.push_back(CUTE(shouldMultiplyByZero)); s.push_back(CUTE(shouldMultiplyTwoNegativeNumbers)); s.push_back(CUTE(shouldMultiplyTwoNumbers)); s.push_back(CUTE(shouldModuloTwoNumbers)); s.push_back(CUTE(shouldModuloTwoNegativeNumbers)); s.push_back(CUTE(testUnknownOperator)); s.push_back(CUTE(testIStreamWay)); cute::xml_file_opener xmlfile(argc,argv); cute::xml_listener<cute::ide_listener<> > lis(xmlfile.out); cute::makeRunner(lis,argc,argv)(s, "AllTests"); }
int main() { memset(wire, -1, sizeof(wire)); memset(cache, -1, sizeof(cache)); scanf("%d", &N); int a, b; for(int i=1; i<=N; i++) { scanf("%d %d", &a, &b); wire[a] = b; if(a > max) { //인덱스로 사용할 전깃줄의 번호중 가장 큰 수 max = a; } } int maxLis = -1; for(int i=1; i<=max; i++) { if(wire[i] != -1) { maxLis = (MAX(maxLis, lis(i))); } } printf("%d\n", N - maxLis); return 0; }
int main() { int itr; int nCount; scanf("%d", &nCount); for(itr=0; itr<nCount; itr++) { memset(cache, -1, sizeof(cache)); scanf("%d", &N); for(int i=0; i<N; i++) { scanf("%d", &input[i]); } int maxV = -1; for(int start=0; start<N; start++) { maxV = (MAX(maxV, lis(start))); } printf("%d\n", maxV); } return 0; }
int main(){ int w, s, n=0, i, r; while(scanf("%d %d",&w, &s)!=EOF){ inp[n].id = n+1; inp[n].w = w; inp[n].s = s; n++; } qsort(inp, n, sizeof(elephant), &compar); r=lis(n); printf("%d\n", r); n=r; i=M[r]; while(r){ seq[r-1] = inp[i].id; i=P[i]; r--; } for(i=0;i<n;i++){ printf("%d\n",seq[i]); } }
int main() { int n, nCount; scanf("%d\n", &nCount); for (n = 0; n<nCount; n++) { int i; int temp; scanf("%d", &N); // Init for (i = 0; i < N; i++) { cache[i] = -1; } for (i = 0; i < N; i++) { scanf("%d", &num[i]); } max = -1; for (i = 0; i < N; i++) { temp = lis(i); if(max < temp) max = temp; } printf("%d\n", max); } return 0; }
void proc() { scanf("%d", &n); for(int i = 0; i < n; ++i) scanf("%d", &arr[i]); printf("%d\n", lis()); }
int main() { for(; ~scanf("%d",&n);) { for(i=0; i<n; i++)scanf("%d",x+i); printf("%d\n",lis(n)); } }
/** * @return all non repeating events */ ODateBookAccess::List ODateBookAccess::nonRepeats()const { QArray<int> ints = m_backEnd->nonRepeats(); List lis( ints, this ); return lis; }
/** * @return all events available */ ODateBookAccess::List ODateBookAccess::rawEvents()const { QArray<int> ints = m_backEnd->rawEvents(); List lis( ints, this ); return lis; }
int main(){ for(scanf("%d",&n);i<n;i++)scanf("%d",x+i); printf("%d\n",lis(n)); }
void GLForm::paintGL() { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef( hSteps , vSteps , -10+numSteps ); glTranslatef(-eyex, -eyey, -eyez); // gluLookAt(1.0, 1.0,1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glRotatef(rotationX, 1.0, 0.0, 0.0); //旋转时重绘用 glRotatef(rotationY, 0.0, 1.0, 0.0); glRotatef(rotationZ, 0.0, 0.0, 1.0); //glPushMatrix(); glBegin(GL_LINES); glColor3f(1.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(100.0, 0.0, 0.0); glColor3f(0.0, 1.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 100.0, 0.0); glColor3f(0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 100.0); glEnd(); glBegin(GL_POINTS); glColor3f(1.0, 0.0, 0.0); glVertex3f(eyex, eyey, eyez); glPointSize(1.0); glColor3f(0.2, 0.5, 1.0); QVector3D vpt; QLinkedListIterator<QVector3D> lis(pt); while(lis.hasNext()) { vpt =lis.next(); glVertex3f(vpt.x(), vpt.y(), vpt.z()); } // while(!pt.isEmpty()){ // vpt = pt.first(); // pt.removeFirst(); // glVertex3f(vpt.x(), vpt.y(), vpt.z()); // } glColor3f(1.0, 1.0, 0.2); for(int i=0; i<spt.size(); i++) { glVertex3f(spt[i].x(), spt[i].y(), spt[i].z()); } glColor3f(1.0, 0.2, 1.0); for(int i=0; i<contour.size(); i += 5) { for(int j=0; j<contour[i].size(); j++) glVertex3f(contour.at(i).at(j).x(), contour.at(i).at(j).y(), contour.at(i).at(j).z()); } glEnd(); // glPopMatrix(); glFlush(); }
void main(){ lis(0,4); printf("%d",maxt); }