CODE FESTIVAL 2016 Grand Final(Parallel)

Submission #1291474

Source codeソースコード

#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i32 n;
vec<i64> a, b;

i32 main()
{
	cin >> n;
	a.resize(n); b.resize(n);
	times(n, i) { cin >> a[i]; }
	times(n, i) { cin >> b[i]; }
	sortall(a);
	sortall(b);
	i64 ans = 1;
	times(n, i) {
		i32 cnt;
		if (a[i] < b[i]) {
			cnt = distance(a.begin(), findge(all(a), b[i])) - i;
		} else {
			cnt = distance(b.begin(), findge(all(b), a[i])) - i;
		}
		ans = (ans * cnt) % MOD;
	}
	cout << ans << endl;
    return 0;
}

Submission

Task問題 A - 1D Matching
User nameユーザ名 Tatsuno
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 500
Source lengthソースコード長 1330 Byte
File nameファイル名
Exec time実行時間 99 ms
Memory usageメモリ使用量 1792 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0.txt,example1.txt
All 500 / 500 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
000.txt AC 59 ms 1152 KB
001.txt AC 22 ms 640 KB
002.txt AC 30 ms 768 KB
003.txt AC 34 ms 768 KB
004.txt AC 87 ms 1664 KB
005.txt AC 99 ms 1792 KB
006.txt AC 97 ms 1792 KB
007.txt AC 97 ms 1792 KB
008.txt AC 97 ms 1792 KB
009.txt AC 97 ms 1792 KB
010.txt AC 96 ms 1792 KB
011.txt AC 98 ms 1792 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB