Submission #1000595


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

const int md = 1000000007;

const int N = 1234567;

pair <int, int> a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n + n; i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a, a + n + n);
  int ans = 1;
  int balance = 0;
  for (int i = 0; i < n + n; i++) {
    if (a[i].second < n) {
      if (balance < 0) {
        ans = (long long) ans * (-balance) % md;
      }
      balance++;
    } else {
      if (balance > 0) {
        ans = (long long) ans * balance % md;
      }
      balance--;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
                  ^
./Main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a[i].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 43 ms 1792 KB
009.txt AC 42 ms 1792 KB
010.txt AC 42 ms 1792 KB
011.txt AC 42 ms 1792 KB
example0.txt AC 3 ms 256 KB
example1.txt AC 3 ms 256 KB