답안 #535011

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535011 2022-03-09T09:32:42 Z radal Naan (JOI19_naan) C++17
100 / 100
437 ms 96696 KB
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#define rep(i,l,r) for (int i = l; i < r; i++)
#define repr(i,r,l) for (int i = r; i >= l; i--)
#define X first
#define Y second
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " : " << x << endl;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
constexpr ll N = 2e3+20,mod = 1e9+7,inf = 1e9+10,maxm = 1e6;
inline int mkay(int a,int b){
    if (a+b >= mod) return a+b-mod;
    if (a+b < 0) return a+b+mod;
    return a+b;
}
 
inline int poww(int a,int k){
    if (k < 0) return 0;
    int z = 1;
    while (k){
        if (k&1) z = 1ll*z*a%mod;
        a = 1ll*a*a%mod;
        k >>= 1;
    }
    return z;
}
int n,l;
ll a[N][N],sum[N];
pll nxt[N][N];
bool mark[N];
int cmp(pll x,pll y){
    ll f1 = x.X*(y.Y/n) ,f2 = y.X * (x.Y/n);
    if (f1 == f2) return 0;
    if (f1 < f2) return 1;
    return -1;
}
int main(){
    ios :: sync_with_stdio(0); cin.tie(0);
    cin >> n >> l;
    rep(i,0,n){ 
        rep(j,0,l){
            cin >> a[i][j];
            sum[i] += a[i][j];
        }
        ll cur = 0;
        int k = 0;
        rep(j,0,n){
            for (;cur + a[i][k]*n <= sum[i]*(j+1) && k < l; k++)
                cur += a[i][k]*n;
            if (k >= l) nxt[i][j] = {l,1};
            else nxt[i][j] = {sum[i]*(j+1)+k*a[i][k]*n-cur,a[i][k]*n};
        }
    }
    vector<int> ans;
    vector<pll> out;
    rep(g,0,n-1){
        pll mi = {inf,1};
        int j = 0;
        rep(i,0,n){
            if (mark[i]) continue;
            if (cmp(mi,nxt[i][g]) == -1){
                mi = nxt[i][g];
                j = i;
            }
        }
        ans.pb(j+1);
        out.pb(mi);
        mark[j] = 1;
    }
    rep(i,0,n) if (!mark[i]) ans.pb(i+1);
    for (pll p : out) cout << p.X << ' ' << p.Y << endl;
    for (int u : ans) cout << u << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 312 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 460 KB Output is correct
34 Correct 1 ms 460 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 328 KB Output is correct
40 Correct 1 ms 312 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 328 KB Output is correct
43 Correct 39 ms 13288 KB Output is correct
44 Correct 193 ms 55356 KB Output is correct
45 Correct 120 ms 23048 KB Output is correct
46 Correct 17 ms 4036 KB Output is correct
47 Correct 156 ms 35792 KB Output is correct
48 Correct 117 ms 75264 KB Output is correct
49 Correct 43 ms 24012 KB Output is correct
50 Correct 202 ms 91976 KB Output is correct
51 Correct 126 ms 39408 KB Output is correct
52 Correct 229 ms 81564 KB Output is correct
53 Correct 209 ms 77352 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 45 ms 43852 KB Output is correct
56 Correct 175 ms 53640 KB Output is correct
57 Correct 111 ms 47376 KB Output is correct
58 Correct 160 ms 76220 KB Output is correct
59 Correct 154 ms 43480 KB Output is correct
60 Correct 431 ms 96568 KB Output is correct
61 Correct 406 ms 96484 KB Output is correct
62 Correct 437 ms 96356 KB Output is correct
63 Correct 416 ms 96628 KB Output is correct
64 Correct 409 ms 96696 KB Output is correct
65 Correct 303 ms 96576 KB Output is correct
66 Correct 294 ms 96500 KB Output is correct
67 Correct 328 ms 96440 KB Output is correct
68 Correct 159 ms 55260 KB Output is correct
69 Correct 170 ms 49884 KB Output is correct
70 Correct 198 ms 66552 KB Output is correct
71 Correct 280 ms 72280 KB Output is correct