Accounting | Trading | Tools | Accounts | Login
Kurniady Systems - Tools
 
Tuesday, 07 September 2010 - 17:06:18
Home | About

Viewing Text Document

Title:

INC 2008 Final D

Owner: Andrian Kurniady

Last updated on: Tuesday, 15 July 2008

Description:

My solution for INC 2008 final problem D.

Content:

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <math.h>
using namespace std;

int main(){
    int ntc;
    scanf("%d", &ntc);
    while (ntc--){
          int n,m;
          scanf("%d%d", &n,&m);
          vector<int> as,bs;
          for( int i=0;i<n;i++){
            int x;
            scanf("%d", &x);
            as.push_back(x);       
        }
          for( int i=0;i<m;i++){
            int x;
            scanf("%d", &x);
            bs.push_back(x);       
        }
        long long res = 0;
        sort(as.begin(), as.end());
        sort(bs.begin(), bs.end());
        for (int i=0;i<n;i++){
            int lopos = lower_bound(bs.begin(), bs.end(), as[i])-bs.begin();
            res += lopos;
        }
        printf("%I64d\n", res);
    }
    
    return 0;
}

Please note that the document shown may be copyrighted. Please contact the owner of this document for the details.
Valid XHTML and CSS. Powered by Ruby on Rails.
 
Copyright © 2008 by Andrian Kurniady. All rights reserved.