Submission #1244109


Source Code Expand

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <time.h>
#include <sys/timeb.h>
 
using namespace std;
 
int get_time(string r)
{
	struct timeb rawtime;
	ftime(&rawtime);
	static int ms = rawtime.millitm;
	static unsigned long s = rawtime.time;
	int out_ms = rawtime.millitm - ms;
	unsigned long out_s = rawtime.time - s;
	if (out_ms < 0)
	{
		out_ms += 1000;
		out_s -= 1;
	}
	ms = rawtime.millitm;
	s = rawtime.time;
	int total = 1000*out_s+out_ms;
	cout<<r<<": "<<total<<"ms"<<endl;
	return total;
}
 
bool cmp(pair<int, int> a, pair<int, int> b) {
	return a.first < b.first;
}
 
int main(int argc, char *argv[]) {
//	get_time("begin");
	
	long beMod = 10e9+7;
	int N;
	int a, b;
	vector<pair<int, int>> all;
	cin >> N;
	for (int i = 0; i < N; i++)
		cin>>a, all.emplace_back(a, 1);
	for (int i = 0; i < N; i++)
		cin>>b, all.emplace_back(b, -1);
		
	sort(all.begin(), all.end());
	
	vector<long> f(100001); //factorial
	f[0] = 1;
	for (int i = 1; i <= 100000; i++)
		f[i] = (f[i - 1] * i) % beMod;
		
//	for (int i = 0; i < 2 * N; i++) cout<<all[i].first<<endl;
	
	long cnt = 0, res = 1;
	for(int i=0;i<all.size();i++){
		if(all[i].second==1){
			if(cnt < 0) res = res * -cnt % beMod;
			cnt++;
		}
		else{
			if(cnt > 0) res = res * cnt % beMod;
			cnt--;
		}
	}
	
	cout<<res<<endl;
	
//	get_time("end");
	return 0;
} 

Submission Info

Submission Time
Task A - 1D Matching
User elfredayao
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1452 Byte
Status WA
Exec Time 98 ms
Memory 2544 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 3
WA × 11
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt WA 60 ms 2164 KB
001.txt WA 23 ms 1528 KB
002.txt WA 31 ms 1656 KB
003.txt WA 35 ms 1780 KB
004.txt WA 88 ms 2420 KB
005.txt WA 98 ms 2544 KB
006.txt WA 98 ms 2544 KB
007.txt WA 98 ms 2544 KB
008.txt WA 98 ms 2544 KB
009.txt WA 98 ms 2544 KB
010.txt WA 97 ms 2544 KB
011.txt AC 98 ms 2544 KB
example0.txt AC 2 ms 1024 KB
example1.txt AC 2 ms 1024 KB