# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
703817 |
2023-02-28T12:57:01 Z |
LittleCube |
Naan (JOI19_naan) |
C++14 |
|
335 ms |
94660 KB |
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
const bool LittleCubeIsBurningChicken = true;
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll N, L, v[2005][2005], sum[2005];
bool vis[2005];
pll d[2005][2005];
int abtodc(int a, int b, int c)
{
return (b * c + a - 1) / a;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> N >> L;
// why divide by N?
// how to solve using only fractions? -> we can discard leftovers (things cannot be converted to current fraction) from last person
// is it guarnteed to always have a solution? -> yes (at least for N <= 6)
// why?
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= L; j++)
{
cin >> v[i][j];
// sum >= sum of v / N
// sum * N >= sum of v
sum[i] += v[i][j];
v[i][j] *= N;
}
}
for (int i = 1; i <= N; i++)
{
pll last = {0, 1};
int nxt = 1;
for (int j = 1; j <= N; j++)
{
ll tmp = sum[i];
while (nxt < L && tmp >= v[i][nxt] - last.F)
tmp -= v[i][nxt] - last.F, last = {0, 1}, nxt++;
last = {last.F, v[i][nxt]};
last.F += tmp;
d[i][j] = pll(last.F + (nxt - 1) * last.S, last.S);
}
}
vector<int> p;
for (int i = 1; i <= N; i++)
{
pll cur = {1e9, 1};
int nxt = 0;
for (int j = 1; j <= N; j++)
if (!vis[j] && (__int128)d[j][i].F * cur.S < (__int128)d[j][i].S * cur.F)
nxt = j, cur = d[j][i];
vis[nxt] = 1;
if (i < N)
cout << cur.F << ' ' << cur.S << '\n';
p.emplace_back(nxt);
}
for (int i = 0; i < N; i++)
cout << p[i] << " \n"[i == N - 1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
0 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
468 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
0 ms |
340 KB |
Output is correct |
39 |
Correct |
1 ms |
340 KB |
Output is correct |
40 |
Correct |
1 ms |
340 KB |
Output is correct |
41 |
Correct |
0 ms |
340 KB |
Output is correct |
42 |
Correct |
1 ms |
340 KB |
Output is correct |
43 |
Correct |
25 ms |
11868 KB |
Output is correct |
44 |
Correct |
153 ms |
53876 KB |
Output is correct |
45 |
Correct |
97 ms |
21372 KB |
Output is correct |
46 |
Correct |
15 ms |
2880 KB |
Output is correct |
47 |
Correct |
119 ms |
34380 KB |
Output is correct |
48 |
Correct |
96 ms |
73456 KB |
Output is correct |
49 |
Correct |
36 ms |
22988 KB |
Output is correct |
50 |
Correct |
179 ms |
90048 KB |
Output is correct |
51 |
Correct |
98 ms |
37860 KB |
Output is correct |
52 |
Correct |
195 ms |
79952 KB |
Output is correct |
53 |
Correct |
147 ms |
75976 KB |
Output is correct |
54 |
Correct |
1 ms |
340 KB |
Output is correct |
55 |
Correct |
38 ms |
43600 KB |
Output is correct |
56 |
Correct |
121 ms |
52072 KB |
Output is correct |
57 |
Correct |
97 ms |
45900 KB |
Output is correct |
58 |
Correct |
131 ms |
74744 KB |
Output is correct |
59 |
Correct |
120 ms |
41936 KB |
Output is correct |
60 |
Correct |
335 ms |
94524 KB |
Output is correct |
61 |
Correct |
330 ms |
94460 KB |
Output is correct |
62 |
Correct |
332 ms |
94140 KB |
Output is correct |
63 |
Correct |
329 ms |
94460 KB |
Output is correct |
64 |
Correct |
320 ms |
94624 KB |
Output is correct |
65 |
Correct |
241 ms |
94500 KB |
Output is correct |
66 |
Correct |
245 ms |
94660 KB |
Output is correct |
67 |
Correct |
249 ms |
94536 KB |
Output is correct |
68 |
Correct |
123 ms |
54212 KB |
Output is correct |
69 |
Correct |
144 ms |
48812 KB |
Output is correct |
70 |
Correct |
137 ms |
65680 KB |
Output is correct |
71 |
Correct |
219 ms |
71160 KB |
Output is correct |