ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211388 | #3806. 逃跑 | rua | 90 | 2808ms | 13772kb | C++11 | 1.7kb | 2024-08-11 09:43:19 | 2024-08-11 13:01:44 |
answer
#include <bits/stdc++.h>
#define inf INT_MAX
#define NN INT_MIN
typedef long long ll;
using namespace std;
ll a[10][200005];
ll v[200005];
int vis[10];
ll ans = 0, sum = 0;
int n, m, k;
void dfs(int now)
{
// cout << 111 << endl;
if (now == m + 1)
{
// cout << 111 << endl;
// for (int i = 1; i <= m; i++)
// {
// v[i] = 0;
// for (int j = 1; j <= n; j++)
// v[i] += a[i][j] * ((k[i] == 1) ? -1 : 1);
// }
for (int i = 1; i <= n; i++)
{
// cout << 111 << endl;
v[i] = 0;
for (int j = 1; j <= m; j++)
v[i] += a[j][i] * ((vis[j] == 1) ? -1 : 1);
// cout << 111 << endl;
}
// cout << 111 << endl;
sort(v + 1, v + n + 1);
sum = 0;
for (int i = 1; i <= k; i++)
sum += v[n - i + 1];
ans = max(ans, sum);
return;
}
dfs(now + 1);
vis[now] = 1;
dfs(now + 1);
vis[now] = 0;
}
int main()
{
#ifdef WHX_AK_IOI
freopen("data.in", "r", stdin);
// freopen("dataout.txt","w",stdout);
#endif
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n >> m >> k;
// for (int i = 1; i <= n; i++)
// {
// for (int j = 1; j <= m; j++)
// cout << a[j][i] << ' ';
// cout << endl;
// }
// cout << 1;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[j][i];
// for (int i = 1; i <= n; i++)
// {
// for (int j = 1; j <= m; j++)
// cout << a[j][i] << ' ';
// cout << endl;
// }
dfs(1);
cout << ans << endl;
// system("pause");
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1292kb
input:
16 6 10 -8117570516 9044069943 -8048766531 -8085807376 9028744360 -2291836940 8616476021 250513762 9...
output:
231924481827
result:
ok "231924481827"
Test #2:
score: 10
Accepted
time: 0ms
memory: 1304kb
input:
18 8 15 -6677000484 -1719283852 4578001104 8068813014 -80018326 4784041624 -1445243501 5746477070 -4...
output:
266922244841
result:
ok "266922244841"
Test #3:
score: 10
Accepted
time: 27ms
memory: 2836kb
input:
100000 1 30000 -8076175068 4904794051 9104341999 1200537137 7000920774 9670819374 -8604644357 -63778...
output:
210324135222440
result:
ok "210324135222440"
Test #4:
score: 10
Accepted
time: 47ms
memory: 4400kb
input:
200000 1 150000 -2272499492 -8807500507 3725379627 7512017895 4166123214 1269935574 -8584261761 -751...
output:
378098351320197
result:
ok "378098351320197"
Test #5:
score: 10
Accepted
time: 50ms
memory: 3620kb
input:
100000 2 50000 5241196316 8333678776 -5242651186 5299526105 9464328294 -6643098907 -7209213944 -2118...
output:
334633112402130
result:
ok "334633112402130"
Test #6:
score: 10
Accepted
time: 84ms
memory: 4408kb
input:
100000 3 77777 -6171366053 3327407178 6863027058 -2358761813 -865379553 7668502806 -1462046286 16445...
output:
301554475123255
result:
ok "301554475123255"
Test #7:
score: 10
Accepted
time: 159ms
memory: 5196kb
input:
100000 4 80000 1342329756 468586460 -1031261932 -4571220835 8804945368 3053813574 4285088604 5648487...
output:
328766632686396
result:
ok "328766632686396"
Test #8:
score: 10
Accepted
time: 281ms
memory: 5976kb
input:
100000 5 50000 2090638820 9317267787 6793358676 4188448984 -9559977197 7940656860 -2874312253 -64757...
output:
526871256881132
result:
ok "526871256881132"
Test #9:
score: 10
Accepted
time: 2160ms
memory: 13772kb
input:
200000 7 150000 9971130068 -8676993799 6080041194 -2943164240 -8998382194 9328104368 -6115122293 -24...
output:
993405245943392
result:
ok "993405245943392"
Test #10:
score: 0
Time Limit Exceeded
input:
200000 8 190000 1307391941 4980087558 -8998121420 3485381411 -4347578759 3621016169 4723154919 80775...