# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
131855 | 2019-07-17T19:53:23 Z | hamzqq9 | Naan (JOI19_naan) | C++14 | 927 ms | 96504 KB |
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define ppb pop_back #define ii pair<int,int> #define ll long long #define orta ((bas+son)>>1) #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define inf 10000000000000 #define N 2019 #define MOD 998244353 using namespace std; #define greater bos struct frac { ll u; int d; }; bool greateq(frac a,frac b) { return 1.0*a.u/a.d>=1.0*b.u/b.d; } bool greater(frac a,frac b) { return 1.0*a.u/a.d>1.0*b.u/b.d; } int n,l; int v[N][N],pre[N][N],u[N],ptr[N]; vector<frac> cp[N]; 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]); pre[i][j]=pre[i][j-1]+v[i][j]; } } for(int i=1;i<=n;i++) { cp[i].pb({0,1}); for(int j=1;j<=n;j++) { int bas=1,son=l; while(bas<=son) { if((ll)pre[i][orta]*n<(ll)pre[i][l]*j) bas=orta+1; else son=orta-1; } // w==(j*sum-n*pre[i][son]+son*v[i][bas]*n)/v[i][bas]*n cp[i].pb({(ll)j*pre[i][l]-(ll)n*pre[i][son]+(ll)son*v[i][bas]*n,v[i][bas]*n}); } } vector<frac> res; vector<int> ans; for(int i=1;i<=n;i++) { frac mn={inf,1}; int tut=-1; for(int j=1;j<=n;j++) { if(u[j]) continue ; while(sz(res) && ptr[j]<n && greater(res.back(),cp[j][ptr[j]])) { ++ptr[j]; } if(ptr[j]<n) { if(greater(mn,cp[j][ptr[j]+1])) { mn=cp[j][ptr[j]+1]; tut=j; } } } ans.pb(tut); u[tut]=1; res.pb(mn); } res.ppb(); for(auto x:res) printf("%lld %d\n",x.u,x.d); for(auto x:ans) printf("%d ",x); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 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 | 3 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 | 3 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 372 KB | Output is correct |
11 | Correct | 3 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 | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 4 ms | 504 KB | Output is correct |
5 | Correct | 3 ms | 504 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 504 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 3 ms | 508 KB | Output is correct |
11 | Correct | 3 ms | 504 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 504 KB | Output is correct |
14 | Correct | 3 ms | 504 KB | Output is correct |
15 | Correct | 3 ms | 504 KB | Output is correct |
16 | Correct | 3 ms | 504 KB | Output is correct |
17 | Correct | 3 ms | 508 KB | Output is correct |
18 | Correct | 3 ms | 504 KB | Output is correct |
19 | Correct | 3 ms | 504 KB | Output is correct |
20 | Correct | 3 ms | 504 KB | Output is correct |
21 | Correct | 3 ms | 504 KB | Output is correct |
22 | Correct | 3 ms | 504 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 3 ms | 504 KB | Output is correct |
25 | Correct | 3 ms | 504 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 508 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 | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 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 | 3 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 372 KB | Output is correct |
11 | Correct | 3 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 | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 252 KB | Output is correct |
18 | Correct | 3 ms | 504 KB | Output is correct |
19 | Correct | 4 ms | 504 KB | Output is correct |
20 | Correct | 3 ms | 504 KB | Output is correct |
21 | Correct | 3 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 504 KB | Output is correct |
24 | Correct | 3 ms | 504 KB | Output is correct |
25 | Correct | 3 ms | 508 KB | Output is correct |
26 | Correct | 3 ms | 504 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 504 KB | Output is correct |
29 | Correct | 3 ms | 504 KB | Output is correct |
30 | Correct | 3 ms | 504 KB | Output is correct |
31 | Correct | 3 ms | 504 KB | Output is correct |
32 | Correct | 3 ms | 508 KB | Output is correct |
33 | Correct | 3 ms | 504 KB | Output is correct |
34 | Correct | 3 ms | 504 KB | Output is correct |
35 | Correct | 3 ms | 504 KB | Output is correct |
36 | Correct | 3 ms | 504 KB | Output is correct |
37 | Correct | 3 ms | 504 KB | Output is correct |
38 | Correct | 2 ms | 376 KB | Output is correct |
39 | Correct | 3 ms | 504 KB | Output is correct |
40 | Correct | 3 ms | 504 KB | Output is correct |
41 | Correct | 2 ms | 376 KB | Output is correct |
42 | Correct | 3 ms | 508 KB | Output is correct |
43 | Correct | 77 ms | 14328 KB | Output is correct |
44 | Correct | 446 ms | 57064 KB | Output is correct |
45 | Correct | 247 ms | 21668 KB | Output is correct |
46 | Correct | 33 ms | 2552 KB | Output is correct |
47 | Correct | 311 ms | 31736 KB | Output is correct |
48 | Correct | 270 ms | 82424 KB | Output is correct |
49 | Correct | 98 ms | 25208 KB | Output is correct |
50 | Correct | 469 ms | 94812 KB | Output is correct |
51 | Correct | 242 ms | 38264 KB | Output is correct |
52 | Correct | 491 ms | 80356 KB | Output is correct |
53 | Correct | 390 ms | 78384 KB | Output is correct |
54 | Correct | 3 ms | 504 KB | Output is correct |
55 | Correct | 120 ms | 49656 KB | Output is correct |
56 | Correct | 314 ms | 52316 KB | Output is correct |
57 | Correct | 256 ms | 47144 KB | Output is correct |
58 | Correct | 371 ms | 79608 KB | Output is correct |
59 | Correct | 284 ms | 42424 KB | Output is correct |
60 | Correct | 927 ms | 96376 KB | Output is correct |
61 | Correct | 927 ms | 96280 KB | Output is correct |
62 | Correct | 920 ms | 96184 KB | Output is correct |
63 | Correct | 923 ms | 96344 KB | Output is correct |
64 | Correct | 925 ms | 96376 KB | Output is correct |
65 | Correct | 606 ms | 96248 KB | Output is correct |
66 | Correct | 612 ms | 96368 KB | Output is correct |
67 | Correct | 646 ms | 96504 KB | Output is correct |
68 | Correct | 364 ms | 58048 KB | Output is correct |
69 | Correct | 399 ms | 49116 KB | Output is correct |
70 | Correct | 477 ms | 70504 KB | Output is correct |
71 | Correct | 597 ms | 71580 KB | Output is correct |