답안 #203719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203719 2020-02-22T01:04:27 Z ics0503 Naan (JOI19_naan) C++17
100 / 100
1096 ms 188792 KB
#include<stdio.h>
#include<vector>
#include<set>
using namespace std;
set<long long >people;
long long v[2121][2121], S[2121][2121];
struct xy {
	long long x, y;
}need[2121];
long long gcd(long long a, long long b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
struct xyz {
	long long x, y, z;
	void balance() {
		long long g = gcd(y, z);
		y /= g; z /= g;
	}
}L[2121][2121];
bool cmp(xyz a, xyz b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y * b.z < b.y * a.z;
}
vector<long long>ans;
int main() {
	long long n, l, i, j; scanf("%lld%lld", &n, &l);
	for (i = 1; i <= n; i++)people.insert(i);
	for (i = 1; i <= n; i++) {
		L[i][0] = { 1,0,1 };
		for (j = 1; j <= l; j++)scanf("%lld", &v[i][j]), S[i][j] = S[i][j - 1] + v[i][j],need[i].x+=v[i][j];
		need[i].y = n;
		for (j = 1; j < n; j++) {
			L[i][j].x = L[i][j - 1].x;
			while (L[i][j].x<l && (S[i][L[i][j].x]) * need[i].y <= need[i].x * j) {
				L[i][j].x++;
			}

			L[i][j].y = need[i].x * j - S[i][L[i][j].x - 1] * need[i].y;
			L[i][j].z = v[i][L[i][j].x] * need[i].y;
			L[i][j].balance();
		}
	}
	for (i = 1; i < n; i++) {
		xyz mn = { l + 1,0,1 }; long long mnw = 0;
		for (long long who : people) {
			if (cmp(L[who][i], mn)) {
				mn = L[who][i];
				mnw = who;
			}
		}
		printf("%lld %lld\n", (mn.x - 1)*mn.z + mn.y, mn.z);
		people.erase(mnw); ans.push_back(mnw);
	}
	for (long long i = 0; i < ans.size(); i++)printf("%lld ", ans[i]);
	printf("%lld", *people.begin());
	return 0;
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:55:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (long long i = 0; i < ans.size(); i++)printf("%lld ", ans[i]);
                        ~~^~~~~~~~~~~~
naan.cpp:27:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  long long n, l, i, j; scanf("%lld%lld", &n, &l);
                        ~~~~~^~~~~~~~~~~~~~~~~~~~
naan.cpp:31:83: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for (j = 1; j <= l; j++)scanf("%lld", &v[i][j]), S[i][j] = S[i][j - 1] + v[i][j],need[i].x+=v[i][j];
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 9 ms 504 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 7 ms 504 KB Output is correct
10 Correct 6 ms 504 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 6 ms 504 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 7 ms 504 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 632 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 9 ms 504 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 7 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 5 ms 504 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 5 ms 504 KB Output is correct
33 Correct 7 ms 504 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 6 ms 504 KB Output is correct
36 Correct 6 ms 504 KB Output is correct
37 Correct 6 ms 632 KB Output is correct
38 Correct 5 ms 376 KB Output is correct
39 Correct 6 ms 504 KB Output is correct
40 Correct 5 ms 504 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 5 ms 504 KB Output is correct
43 Correct 92 ms 18808 KB Output is correct
44 Correct 550 ms 97420 KB Output is correct
45 Correct 281 ms 44792 KB Output is correct
46 Correct 40 ms 6264 KB Output is correct
47 Correct 375 ms 65108 KB Output is correct
48 Correct 607 ms 120940 KB Output is correct
49 Correct 164 ms 37500 KB Output is correct
50 Correct 836 ms 159992 KB Output is correct
51 Correct 362 ms 68472 KB Output is correct
52 Correct 770 ms 140152 KB Output is correct
53 Correct 655 ms 127992 KB Output is correct
54 Correct 5 ms 504 KB Output is correct
55 Correct 283 ms 66328 KB Output is correct
56 Correct 462 ms 92280 KB Output is correct
57 Correct 375 ms 78844 KB Output is correct
58 Correct 599 ms 123972 KB Output is correct
59 Correct 411 ms 75640 KB Output is correct
60 Correct 1012 ms 188536 KB Output is correct
61 Correct 1014 ms 188280 KB Output is correct
62 Correct 1096 ms 188152 KB Output is correct
63 Correct 1051 ms 188792 KB Output is correct
64 Correct 1070 ms 188664 KB Output is correct
65 Correct 1068 ms 175096 KB Output is correct
66 Correct 1014 ms 175364 KB Output is correct
67 Correct 904 ms 175100 KB Output is correct
68 Correct 397 ms 93560 KB Output is correct
69 Correct 428 ms 90348 KB Output is correct
70 Correct 465 ms 111992 KB Output is correct
71 Correct 635 ms 130040 KB Output is correct