QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#855237 | #9967. Imbalanced Teams | ucup-team3691# | WA | 10ms | 19412kb | C++20 | 2.8kb | 2025-01-12 16:32:31 | 2025-01-12 16:32:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
using ll = long long;
using ull = unsigned long long;
string to_string(const string &s) {
return '"' + s + '"';
}
string to_string(bool b) {
return b ? "true" : "false";
}
template <typename A, typename B>
string to_string(const pair<A, B> &p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(const T &v) {
string s = "{";
bool first = true;
for (const auto &it : v) {
if (!first)
s += ", ";
else
first = false;
s += to_string(it);
}
return s += "}";
}
void debug_out() {
cerr << endl;
}
template <typename T, typename... Args>
void debug_out(const T &first, const Args&... rest) {
cerr << to_string(first) << " ";
debug_out(rest...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
auto startTime = high_resolution_clock::now();
int get_time() {
auto stopTime = chrono::high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stopTime - startTime);
return duration.count(); // in ms
}
const int N = 2000;
const int MOD = 1e9 + 7;
int C[N + 5][N + 5];
void init() {
C[0][0] = 1;
for (int i = 1; i <= N; ++i) {
C[i][0] = 1;
for (int j = 1; j <= i; ++j) {
C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
if (C[i][j] >= MOD)
C[i][j] -= MOD;
}
}
}
void solve() {
int n, k;
cin >> n >> k;
init();
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a.begin(), a.end());
int x = a[k - 1];
int l1 = k - 1;
int s1 = 0, s2 = 0;
for (int i = 0; i < k; ++i) {
s1 += a[i];
s2 += a[n - i - 1];
}
cout << s2 - s1 << " ";
for (int i = k; i < n; ++i) {
if (x == a[i]) {
l1 = i;
} else {
break;
}
}
int y = a[n - k], l2 = n - k;
for (int i = n - k; i >= 0; --i) {
if (y == a[i]) {
l2 = i;
} else {
break;
}
}
int nr1 = k, f1 = 0;
int nr2 = k, f2 = 0;
for (int i = 0; i < n; ++i) {
if (x > a[i]) {
--nr1;
}
if (x == a[i])
++f1;
if (y < a[i]) {
--nr2;
}
if (y == a[i])
++f2;
}
int ans = 1;
if (x == y) {
ans = 1LL * ans * C[f1][nr1] * C[f2 - nr1][nr2] % MOD;
if (a[0] == a[n - 1]) {
ans = C[f1][nr1] * C[f2 - nr1][nr2] / 2 % MOD;
}
} else {
ans = 1LL * ans * C[f1][nr1] * C[f2][nr2] % MOD;
}
cout << ans << "\n";
}
int main() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 10ms
memory: 19112kb
input:
6 2 2 5 7 2 5 2
output:
8 6
result:
ok 2 number(s): "8 6"
Test #2:
score: 0
Accepted
time: 6ms
memory: 18908kb
input:
5 2 1 1 1 1 1
output:
0 15
result:
ok 2 number(s): "0 15"
Test #3:
score: 0
Accepted
time: 6ms
memory: 18580kb
input:
2 1 1 1
output:
0 1
result:
ok 2 number(s): "0 1"
Test #4:
score: 0
Accepted
time: 3ms
memory: 19092kb
input:
2 1 1 2
output:
1 1
result:
ok 2 number(s): "1 1"
Test #5:
score: 0
Accepted
time: 6ms
memory: 19276kb
input:
10 4 3 3 1 2 4 6 2 4 4 1
output:
12 1
result:
ok 2 number(s): "12 1"
Test #6:
score: 0
Accepted
time: 6ms
memory: 19008kb
input:
14 3 57 57 57 57 57 57 57 57 57 57 57 57 57 57
output:
0 30030
result:
ok 2 number(s): "0 30030"
Test #7:
score: 0
Accepted
time: 9ms
memory: 19104kb
input:
13 5 858336 900782 858336 900782 900782 858336 900782 858336 858336 858336 858336 858336 52093
output:
976027 280
result:
ok 2 number(s): "976027 280"
Test #8:
score: 0
Accepted
time: 10ms
memory: 18520kb
input:
14 4 447923 447923 447923 211106 447923 447923 447923 447923 16966 447923 211106 515550 211106 211106
output:
1209035 224
result:
ok 2 number(s): "1209035 224"
Test #9:
score: 0
Accepted
time: 3ms
memory: 18956kb
input:
2000 935 57596 988638 30477 956599 52986 460052 987863 291984 947848 109335 541003 338365 939256 297365 926486 944912 700042 810595 412192 37130 343207 311311 681629 48155 319677 435667 731251 919378 254216 893282 661237 740159 787502 501360 517533 349880 565298 536545 192793 18666 425164 856977 536...
output:
493241703 1
result:
ok 2 number(s): "493241703 1"
Test #10:
score: 0
Accepted
time: 6ms
memory: 18908kb
input:
2000 1000 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101...
output:
0 36237869
result:
ok 2 number(s): "0 36237869"
Test #11:
score: 0
Accepted
time: 3ms
memory: 19248kb
input:
2000 1000 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834...
output:
95671357 1001
result:
ok 2 number(s): "95671357 1001"
Test #12:
score: 0
Accepted
time: 6ms
memory: 18856kb
input:
2000 1000 999763 998795 997229 996607 995585 995585 995080 995080 995080 994251 994251 994251 994169 994158 994051 993410 993410 993410 993410 993410 993410 993410 993410 992448 992314 992176 990170 989664 989638 987205 987205 987205 987205 987205 987205 987067 986997 986233 985924 985707 985180 985...
output:
85351652 417058531
result:
ok 2 number(s): "85351652 417058531"
Test #13:
score: 0
Accepted
time: 9ms
memory: 19060kb
input:
2000 1000 220336 697950 570674 245907 697950 409648 697950 245907 697950 245907 245907 245907 496369 697950 697950 697950 245907 435446 697950 245907 697950 245907 697950 317643 245907 245907 697950 697950 697950 245907 697950 697950 697950 697950 697950 220336 412219 697950 245907 245907 697950 697...
output:
406826343 1001
result:
ok 2 number(s): "406826343 1001"
Test #14:
score: 0
Accepted
time: 9ms
memory: 18492kb
input:
2000 1000 824739 824739 511894 511894 511894 824739 824739 511894 511894 511894 511894 511894 824739 511894 422607 824739 824739 824739 511894 824739 824739 824739 824739 824739 511894 824739 824739 824739 824739 824739 824739 511894 511894 824739 511894 824739 511894 824739 511894 824739 511894 824...
output:
312778791 2
result:
ok 2 number(s): "312778791 2"
Test #15:
score: 0
Accepted
time: 9ms
memory: 19040kb
input:
2000 1000 963877 389725 389725 389725 278964 278964 389725 963877 278964 234531 389725 278964 963877 963877 234531 963877 389725 963877 963877 278964 123625 234531 278964 389725 389725 963877 963877 389725 389725 278964 123625 389725 389725 963877 963877 389725 278964 963877 278964 234531 278964 389...
output:
402934678 571
result:
ok 2 number(s): "402934678 571"
Test #16:
score: 0
Accepted
time: 9ms
memory: 19080kb
input:
2000 1000 810623 810623 215961 213971 72125 810623 810623 810623 456356 376932 739377 810623 810623 810623 810623 724747 810623 810623 810623 445139 417445 487074 810623 810623 115166 810623 810623 810623 810623 156975 682791 810623 810623 502268 810623 810623 148063 697295 810623 617315 187980 8106...
output:
336729651 864576772
result:
ok 2 number(s): "336729651 864576772"
Test #17:
score: 0
Accepted
time: 9ms
memory: 19288kb
input:
2000 1000 15252 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 138241 1382...
output:
530383255 379
result:
ok 2 number(s): "530383255 379"
Test #18:
score: 0
Accepted
time: 9ms
memory: 19412kb
input:
2000 1000 68512 68512 68512 68512 68512 68512 68512 68512 68512 68512 415790 68512 415790 68512 68512 68512 415790 68512 584278 68512 415790 68512 68512 68512 68512 352649 68512 68512 68512 68512 68512 68512 68512 68512 68512 68512 68512 68512 68512 15848 68512 415790 415790 68512 68512 68512 68512 ...
output:
197366653 946019815
result:
ok 2 number(s): "197366653 946019815"
Test #19:
score: -100
Wrong Answer
time: 6ms
memory: 18720kb
input:
1996 35 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 231100 23110...
output:
0 350622079
result:
wrong answer 2nd numbers differ - expected: '732363067', found: '350622079'