# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163941 | 2019-11-16T11:13:07 Z | georgerapeanu | Naan (JOI19_naan) | C++11 | 163 ms | 12424 KB |
#include <cstdio> #include <algorithm> #include <vector> using namespace std; const int NMAX = 2000; const int LMAX = 2000; int n,l; int v[NMAX + 5][LMAX + 5]; pair<long long,long long> split[NMAX + 5][NMAX + 5]; long long sum[NMAX + 5]; bool seen[NMAX + 5]; vector<int> perm; long long gcd(long long a,long long b){ if(!b){ return a; } return gcd(b,a % b); } bool cmp_frac(const pair<long long,long long> &a,const pair<long long,long long> &b){ return (long double)a.first / a.second < (long double)b.first / b.second; } int main(){ scanf("%d %d",&n,&l); for(int i = 1;i <= n;i++){ for(int j = 1;j <= l;j++){ scanf("%d",&v[i][j]); sum[i] += v[i][j]; } } for(int i = 1;i <= n;i++){ long long curr = 0; int last = 0; for(int j = 1;j <= n;j++){ while(last < l && cmp_frac({curr,1},{sum[i] * j,n})){ last++; curr += v[i][last]; } if(j == n){ split[i][j] = {l,1}; } else{ split[i][j] = {last * n * v[i][last] + sum[i] * j - curr * n,n * v[i][last]}; } } } for(int i = 1;i <= n;i++){ int id = -1; for(int j = 1;j <= n;j++){ long long g = gcd(split[j][i].first,split[j][i].second); split[j][i].first /= g; split[j][i].second /= g; if(seen[j]){ continue; } if(id == -1 || cmp_frac(split[j][i],split[id][i])){ id = j; } } if(i < n){ printf("%lld %lld\n",split[id][i].first,split[id][i].second); } perm.push_back(id); seen[id] = true; } for(auto it:perm){ printf("%d ",it); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 376 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 | 376 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 | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 428 KB | Output is correct |
5 | Correct | 3 ms | 420 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 | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 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 | 504 KB | Output is correct |
20 | Correct | 3 ms | 504 KB | Output is correct |
21 | Correct | 4 ms | 380 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 | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 376 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 | 376 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 | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 380 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 | 428 KB | Output is correct |
20 | Correct | 3 ms | 420 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 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 | 5 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 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 | 504 KB | Output is correct |
35 | Correct | 3 ms | 504 KB | Output is correct |
36 | Correct | 4 ms | 380 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 | 163 ms | 12424 KB | Integer parameter [name=B_i] equals to -55095180, violates the range [1, 1000000000] |
44 | Halted | 0 ms | 0 KB | - |