Submission #1833217


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = (int)1e5 + 7;
const int mod = (int)1e9 + 7;

int a[N], b[N];
int dp[N];
ll ans = 1;

main() {
    int n; scanf ("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf ("%d", a + i);
    }
    for (int i = 1; i <= n; i++) {
        scanf ("%d", b + i);
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);

    for (int i = 1; i <= n; i++) {
        int l = i, r = n;
        int q = i;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (a[mid] <= b[i]) {
                l = mid;
                q = mid;
            } else {
                r = mid;
            }
        }
        if (a[r] <= b[i]) q = r;
        l = i, r = n;
        int p = i;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (b[mid] <= a[i]) {
                l = mid;
                p = mid;
            } else {
                r = mid;
            }
        }
        if (b[r] <= a[i]) p = r;
        ans *= (max(p, q) - i + 1);
        ans %= mod;
    }
    printf ("%lld", ans);
}

Submission Info

Submission Time
Task A - 1D Matching
User Shabdan
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1169 Byte
Status AC
Exec Time 46 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf ("%d", &n);
                            ^
./Main.cpp:17:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", a + i);
                            ^
./Main.cpp:20:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", b + i);
                            ^

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 28 ms 768 KB
001.txt AC 10 ms 384 KB
002.txt AC 15 ms 512 KB
003.txt AC 16 ms 512 KB
004.txt AC 41 ms 896 KB
005.txt AC 46 ms 1024 KB
006.txt AC 46 ms 1024 KB
007.txt AC 46 ms 1024 KB
008.txt AC 46 ms 1024 KB
009.txt AC 46 ms 1024 KB
010.txt AC 46 ms 1024 KB
011.txt AC 45 ms 1024 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB