# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163094 | 2019-11-11T11:05:36 Z | georgerapeanu | Naan (JOI19_naan) | C++11 | 45 ms | 4728 KB |
#include <cstdio> #include <algorithm> using namespace std; const long long NMAX = 2000; const long long LMAX = 2000; const long long NUM_LIM = 73616400 ; long long n,l; long long v[NMAX + 5][LMAX + 5]; bool taken[NMAX + 5]; long long perm[NMAX + 5]; long long gcd(long long a,long long b){ return 1; if(!b){ return a; } return gcd(b,a % b); } long long lst_cost[NMAX + 5]; /// apromiated real value * NUM_LIM long long target_cost[NMAX + 5]; long long split[NMAX + 5]; int main(){ scanf("%lld %lld",&n,&l); for(int i = 1;i <= n;i++){ for(int j = 1;j <= l;j++){ scanf("%lld",&v[i][j]); target_cost[i] = target_cost[i] + 1LL * v[i][j] * NUM_LIM; } target_cost[i] = (target_cost[i] / n + (target_cost[i] % n != 0)); } long long last_pos = 0; long long cnt_splits = 0; while(cnt_splits < n - 1){ bool expand = false; for(int i = 1;i <= n;i++){ if(taken[i]){ continue; } lst_cost[i] = lst_cost[i] + ((last_pos / NUM_LIM + 1) * NUM_LIM - last_pos) * v[i][last_pos / NUM_LIM + 1]; expand |= (target_cost[i] <= lst_cost[i]); } last_pos = (last_pos / NUM_LIM + 1) * NUM_LIM; if(expand == false){ continue; } long long bst_frac = 0; int id = -1; for(int i = 1;i <= n;i++){ if(taken[i]){ continue; } if(target_cost[i] <= lst_cost[i]){ long long tmp = lst_cost[i] - target_cost[i]; tmp = tmp / v[i][last_pos / NUM_LIM] + (tmp % v[i][last_pos / NUM_LIM] != 0); if(id == -1 || bst_frac <= tmp){ bst_frac = tmp; id = i; } } } last_pos = last_pos - bst_frac; for(int i = 1;i <= n;i++){ if(taken[i]){ continue; } lst_cost[i] = 0; } split[++cnt_splits] = last_pos; taken[id] = true; perm[cnt_splits] = id; } for(int i = 1;i <= n;i++){ if(taken[i] == false){ perm[n] = i; } } for(int i = 1;i < n;i++){ printf("%lld %lld\n",split[i] / gcd(split[i],NUM_LIM),(long long)(NUM_LIM / gcd(split[i],NUM_LIM))); } for(int i = 1;i <= n;i++){ printf("%lld ",perm[i]); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 296 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 292 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 376 KB | Output is correct |
18 | Correct | 3 ms | 376 KB | Output is correct |
19 | Correct | 3 ms | 376 KB | Output is correct |
20 | Correct | 3 ms | 376 KB | Output is correct |
21 | Correct | 3 ms | 508 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 3 ms | 376 KB | Output is correct |
25 | Correct | 3 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 296 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 380 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 3 ms | 376 KB | Output is correct |
20 | Correct | 3 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 380 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 3 ms | 376 KB | Output is correct |
25 | Correct | 3 ms | 376 KB | Output is correct |
26 | Correct | 3 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 292 KB | Output is correct |
28 | Correct | 3 ms | 376 KB | Output is correct |
29 | Correct | 3 ms | 376 KB | Output is correct |
30 | Correct | 3 ms | 376 KB | Output is correct |
31 | Correct | 3 ms | 376 KB | Output is correct |
32 | Correct | 3 ms | 376 KB | Output is correct |
33 | Correct | 3 ms | 376 KB | Output is correct |
34 | Correct | 3 ms | 376 KB | Output is correct |
35 | Correct | 3 ms | 376 KB | Output is correct |
36 | Correct | 3 ms | 508 KB | Output is correct |
37 | Correct | 3 ms | 376 KB | Output is correct |
38 | Correct | 2 ms | 376 KB | Output is correct |
39 | Correct | 3 ms | 376 KB | Output is correct |
40 | Correct | 3 ms | 376 KB | Output is correct |
41 | Correct | 2 ms | 376 KB | Output is correct |
42 | Correct | 3 ms | 376 KB | Output is correct |
43 | Incorrect | 45 ms | 4728 KB | Not a fair distribution. |
44 | Halted | 0 ms | 0 KB | - |