# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
203648 | 2020-02-21T18:11:57 Z | ics0503 | Naan (JOI19_naan) | C++17 | 78 ms | 19576 KB |
#include<stdio.h> #include<set> #include<vector> using namespace std; set<long long >people; struct xy { long long x, y; } need[2121]; long long gcd(long long a, long long b) { if (b == 0)return a; return gcd(b, a%b); } struct xyz { long long x, y, z; void balance() { long long g = gcd(y, z); y /= g; z /= g; } }L[2121]; bool cmp(xyz a, xyz b) { if (a.x != b.x) return a.x < b.x; return a.y * b.z < b.y * a.z; } long long v[2121][2121], S[2121][2121]; vector<int>ans; int main() { long long n, l, i, j; scanf("%lld%lld", &n, &l); for (i = 1; i <= n; i++)people.insert(i); for (i = 1; i <= n; i++) { for (j = 1; j <= l; j++) { scanf("%lld", &v[i][j]), S[i][j] = S[i][j - 1] + v[i][j]; need[i].x += v[i][j]; } need[i].y = n; long long g = gcd(need[i].x, need[i].y); need[i].x /= g; need[i].y /= g; } long long befa = 1, befx = 0, befy = 1; for (i = 1; i <= n - 1; i++) { xyz mn = { l + 1,0,1 }; long long mnw = 0; for (long long who : people) { if ((befy - befx) * v[who][befa] * need[who].y > need[who].x * befy) { L[who].x = befa; L[who].y = need[who].x*befy - befx*need[who].y*v[who][befa]; L[who].z = need[who].y*v[who][befa] * befy; L[who].balance(); } else { while ((befy - befx) * v[who][befa] * need[who].y + (S[who][L[who].x] - S[who][befa]) * befy * need[who].y <= need[who].x * befy) { L[who].x++; } L[who].y = need[who].x*befy - (befy - befx)*v[who][befa] * need[who].y - (S[who][L[who].x - 1] - S[who][befa])*befy*need[who].y; L[who].z = v[who][L[who].x] * need[who].y * befy; L[who].balance(); } if (cmp(L[who], mn)) { mn = L[who]; mnw = who; } } printf("%lld %lld\n", (mn.x - 1)*mn.z + mn.y, mn.z); befa = mn.x, befx = mn.y, befy = mn.z; people.erase(mnw); ans.push_back(mnw); } for (int i = 0; i < ans.size(); i++)printf("%d ", ans[i]); printf("%lld", *people.begin()); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 504 KB | Output is correct |
4 | Correct | 5 ms | 504 KB | Output is correct |
5 | Correct | 5 ms | 504 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 6 ms | 504 KB | Output is correct |
10 | Correct | 6 ms | 504 KB | Output is correct |
11 | Correct | 6 ms | 504 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 504 KB | Output is correct |
14 | Correct | 6 ms | 504 KB | Output is correct |
15 | Correct | 6 ms | 504 KB | Output is correct |
16 | Correct | 6 ms | 504 KB | Output is correct |
17 | Correct | 6 ms | 504 KB | Output is correct |
18 | Correct | 6 ms | 504 KB | Output is correct |
19 | Correct | 6 ms | 504 KB | Output is correct |
20 | Correct | 6 ms | 504 KB | Output is correct |
21 | Correct | 6 ms | 504 KB | Output is correct |
22 | Correct | 6 ms | 504 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 6 ms | 504 KB | Output is correct |
25 | Correct | 5 ms | 504 KB | Output is correct |
26 | Correct | 5 ms | 376 KB | Output is correct |
27 | Correct | 6 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 6 ms | 504 KB | Output is correct |
19 | Correct | 5 ms | 504 KB | Output is correct |
20 | Correct | 5 ms | 504 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 6 ms | 504 KB | Output is correct |
25 | Correct | 6 ms | 504 KB | Output is correct |
26 | Correct | 6 ms | 504 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 504 KB | Output is correct |
29 | Correct | 6 ms | 504 KB | Output is correct |
30 | Correct | 6 ms | 504 KB | Output is correct |
31 | Correct | 6 ms | 504 KB | Output is correct |
32 | Correct | 6 ms | 504 KB | Output is correct |
33 | Correct | 6 ms | 504 KB | Output is correct |
34 | Correct | 6 ms | 504 KB | Output is correct |
35 | Correct | 6 ms | 504 KB | Output is correct |
36 | Correct | 6 ms | 504 KB | Output is correct |
37 | Correct | 6 ms | 504 KB | Output is correct |
38 | Correct | 5 ms | 376 KB | Output is correct |
39 | Correct | 6 ms | 504 KB | Output is correct |
40 | Correct | 5 ms | 504 KB | Output is correct |
41 | Correct | 5 ms | 376 KB | Output is correct |
42 | Correct | 6 ms | 504 KB | Output is correct |
43 | Runtime error | 78 ms | 19576 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
44 | Halted | 0 ms | 0 KB | - |