Submission #1017315


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
const int MAX_N = 1e5;
const ll MOD = 1e9 + 7;

int main()
{
	scanf("%d",&N);
	vector< pair<int,bool> > A(N * 2);
	FOR(i,0,N){
		scanf("%d",&A [i].first);
		A [i].second = true;
	}
	FOR(i,0,N){
		scanf("%d",&A [i + N].first);
	}
	sort(ALL(A));

	ll ans = 1,cnt = 0;
	FOR(i,0,N * 2){
		if(A [i].second){
			if(cnt < 0){
				(ans *= abs(cnt)) %= MOD;
			}
			cnt++;
		}
		else{
			if(cnt > 0){
				(ans *= abs(cnt)) %= MOD;
			}
			cnt--;
		}
	}

	printf("%lld\n",ans);

	return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User gigime
Language C++14 (GCC 5.4.1)
Score 500
Code Size 864 Byte
Status AC
Exec Time 42 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
                ^
./Main.cpp:19:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&A [i].first);
                           ^
./Main.cpp:23:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&A [i + N].first);
                               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 14
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 AC 26 ms 1152 KB
001.txt AC 11 ms 640 KB
002.txt AC 14 ms 768 KB
003.txt AC 16 ms 768 KB
004.txt AC 38 ms 1664 KB
005.txt AC 42 ms 1792 KB
006.txt AC 42 ms 1792 KB
007.txt AC 42 ms 1792 KB
008.txt AC 42 ms 1792 KB
009.txt AC 42 ms 1792 KB
010.txt AC 41 ms 1792 KB
011.txt AC 42 ms 1792 KB
example0.txt AC 3 ms 256 KB
example1.txt AC 3 ms 256 KB