Submission #164759

# Submission time Handle Problem Language Result Execution time Memory
164759 2019-11-23T07:59:39 Z ho94949 Naan (JOI19_naan) C++17
100 / 100
653 ms 38556 KB
#include<bits/stdc++.h>
using namespace std;
int V[2020][2020];
int N, L;

int cur = 0;
long long sumv[2020], now[2020], cut[2020];
bool used[2020];
int P[2020];
// previous now: cur + now[i]/(N*V[i][cur])
// cut: N*(earned)
int main()
{
    scanf("%d%d", &N, &L);
    for(int i=0; i<N; ++i)
        for(int j=0; j<L; ++j)
        {
            scanf("%d", &V[i][j]);
            sumv[i] += V[i][j];
        }
    int phase = 0;
    while(phase < N-1)
    {
        int nextint = cur+1;

        // minv = f/s
        long long f, s;
        int mini = -1;
        for(int i=0; i<N; ++i)
        {
            if(used[i]) continue;
            long long earn = N*V[i][cur] - now[i];
            if(cut[i] + earn >= sumv[i])
            {
                //ok, can be used
                long long nf = now[i] + sumv[i]-cut[i];
                long long ns = N*V[i][cur];
                if(mini == -1 || f*ns > s*nf)
                {
                    f = nf;
                    s = ns;
                    mini = i;
                }
            }
            else
                cut[i] += earn;
        }
        if(mini != -1)
        {
            printf("%lld %lld\n", cur*s+f, s);
            P[phase] = mini;
            used[mini] = true;
            for(int i=0; i<N; ++i) cut[i] = 0;
            for(int i=0; i<N; ++i)
            {
                if(used[i]) continue;
                long long base = N*V[i][cur];
                long long upper = (f*base+s-1)/s;
                now[i] = upper;
            }
            ++phase;
        }
        else
        {
            ++cur;
            for(int i=0; i<N; ++i) now[i] = 0;
        }
    }
    for(int i=0; i<N-1; ++i)
        printf("%d ", P[i]+1);
    
    for(int i=0; i<N; ++i) if(!used[i]) printf("%d\n", i+1);
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:24:13: warning: unused variable 'nextint' [-Wunused-variable]
         int nextint = cur+1;
             ^~~~~~~
naan.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &L);
     ~~~~~^~~~~~~~~~~~~~~~
naan.cpp:18:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &V[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 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 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 3 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 3 ms 504 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 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory 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 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 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 4 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 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 3 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 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 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 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 3 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 3 ms 504 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 504 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 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 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 4 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 376 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 380 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 376 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 Correct 48 ms 4600 KB Output is correct
44 Correct 287 ms 12528 KB Output is correct
45 Correct 194 ms 7160 KB Output is correct
46 Correct 32 ms 2424 KB Output is correct
47 Correct 226 ms 9576 KB Output is correct
48 Correct 142 ms 12664 KB Output is correct
49 Correct 63 ms 7032 KB Output is correct
50 Correct 301 ms 17528 KB Output is correct
51 Correct 176 ms 9976 KB Output is correct
52 Correct 344 ms 15352 KB Output is correct
53 Correct 255 ms 15140 KB Output is correct
54 Correct 3 ms 376 KB Output is correct
55 Correct 48 ms 6904 KB Output is correct
56 Correct 226 ms 12100 KB Output is correct
57 Correct 184 ms 11384 KB Output is correct
58 Correct 237 ms 15240 KB Output is correct
59 Correct 223 ms 10680 KB Output is correct
60 Correct 627 ms 16284 KB Output is correct
61 Correct 622 ms 16632 KB Output is correct
62 Correct 634 ms 16224 KB Output is correct
63 Correct 641 ms 38556 KB Output is correct
64 Correct 653 ms 38260 KB Output is correct
65 Correct 493 ms 24892 KB Output is correct
66 Correct 478 ms 25080 KB Output is correct
67 Correct 486 ms 24932 KB Output is correct
68 Correct 233 ms 17268 KB Output is correct
69 Correct 276 ms 17912 KB Output is correct
70 Correct 246 ms 19196 KB Output is correct
71 Correct 393 ms 24024 KB Output is correct