답안 #123725

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123725 2019-07-02T05:38:57 Z 박상수(#3035) Naan (JOI19_naan) C++14
100 / 100
641 ms 101624 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, L;
int A[2020][2020];
pll P[2020][2020];
pll ans[2020];
int perm[2020];

int main() {
	scanf("%d%d", &N, &L);
	for(int i=1;i<=N;i++) for(int j=1;j<=L;j++) scanf("%d", A[i] + j);
	for(int i=1;i<=N;i++) {
		int sum = 0;
		for(int j=1;j<=L;j++) sum += A[i][j];
		int j = 0, now = 0;
		for(int k=1;k<=N;k++) {
			while(1) {
				if((ll)sum * k <= (ll)(now + A[i][j+1]) * N) {
					ll delta = (ll)sum * k - (ll)now * N;
					P[i][k] = pll(delta + (ll)A[i][j+1] * N * j, A[i][j+1] * N);
					break;
				}
				else ++j, now += A[i][j];
			}
		}
	}
	int chk[2020] = {};
	for(int i=1;i<=N;i++) {
		int f = -1;
		for(int j=1;j<=N;j++) if(chk[j] == 0) {
			if(f == -1) f = j;
			else {
				if((__int128)P[f][i].Fi * P[j][i].Se > (__int128)P[j][i].Fi * P[f][i].Se) f = j;
			}
		}
		perm[i] = f;
		chk[f] = 1;
		ans[i] = P[f][i];
	}
	for(int i=1;i<N;i++) printf("%lld %lld\n", ans[i].Fi, ans[i].Se);
	for(int i=1;i<=N;i++) printf("%d ", perm[i]); puts("");
	return 0;
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:70:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=1;i<=N;i++) printf("%d ", perm[i]); puts("");
  ^~~
naan.cpp:70:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=1;i<=N;i++) printf("%d ", perm[i]); puts("");
                                                ^~~~
naan.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &L);
  ~~~~~^~~~~~~~~~~~~~~~
naan.cpp:40:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=N;i++) for(int j=1;j<=L;j++) scanf("%d", A[i] + j);
                                              ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 380 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 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 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 376 KB Output is correct
5 Correct 3 ms 376 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 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 2 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 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
# 결과 실행 시간 메모리 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 380 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 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 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 3 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 2 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 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 54 ms 10872 KB Output is correct
44 Correct 301 ms 45824 KB Output is correct
45 Correct 200 ms 23416 KB Output is correct
46 Correct 31 ms 3192 KB Output is correct
47 Correct 233 ms 35320 KB Output is correct
48 Correct 172 ms 72312 KB Output is correct
49 Correct 73 ms 22108 KB Output is correct
50 Correct 342 ms 83812 KB Output is correct
51 Correct 196 ms 33528 KB Output is correct
52 Correct 388 ms 73756 KB Output is correct
53 Correct 296 ms 69836 KB Output is correct
54 Correct 3 ms 376 KB Output is correct
55 Correct 68 ms 43384 KB Output is correct
56 Correct 252 ms 46300 KB Output is correct
57 Correct 202 ms 40824 KB Output is correct
58 Correct 265 ms 69924 KB Output is correct
59 Correct 236 ms 37368 KB Output is correct
60 Correct 630 ms 101416 KB Output is correct
61 Correct 629 ms 101340 KB Output is correct
62 Correct 641 ms 101240 KB Output is correct
63 Correct 626 ms 101624 KB Output is correct
64 Correct 638 ms 101536 KB Output is correct
65 Correct 482 ms 87988 KB Output is correct
66 Correct 482 ms 88312 KB Output is correct
67 Correct 486 ms 88184 KB Output is correct
68 Correct 238 ms 52728 KB Output is correct
69 Correct 283 ms 46840 KB Output is correct
70 Correct 272 ms 64344 KB Output is correct
71 Correct 419 ms 69880 KB Output is correct