답안 #55092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55092 2018-07-06T03:51:43 Z ainta(#1558) Sushi (JOI16_sushi) C++11
20 / 100
817 ms 21384 KB
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
int n, Q, w[401000];
multiset<int>Set;
int main() {
	int i;
	int a, b, c, t;
	scanf("%d%d", &n, &Q);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
	}
	if (n <= 2000 && Q <= 2000) {
		while (Q--) {
			scanf("%d%d%d", &a, &b, &c);
			while (1) {
				if (c <= w[a]) {
					t = w[a];
					w[a] = c;
					c = t;
				}
				if (a == b)break;
				a = a%n + 1;
			}
			printf("%d\n", c);
		}
		return 0;
	}
	for (i = 1; i <= n; i++) {
		Set.insert(w[i]);
	}
	multiset<int>::iterator it;
	while (Q--) {
		scanf("%d%d%d", &a, &b, &c);
		it = Set.end();
		it--;
		if ((*it) < c) {
			printf("%d\n", c);
		}
		else {
			printf("%d\n", *it);
			Set.erase(it);
			Set.insert(c);
		}
	}
}

Compilation message

telegraph.cpp: In function 'int main()':
telegraph.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &Q);
  ~~~~~^~~~~~~~~~~~~~~~
telegraph.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &w[i]);
   ~~~~~^~~~~~~~~~~~~
telegraph.cpp:16:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d%d", &a, &b, &c);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~
telegraph.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &a, &b, &c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 248 KB Output is correct
2 Correct 28 ms 356 KB Output is correct
3 Correct 32 ms 408 KB Output is correct
4 Correct 29 ms 408 KB Output is correct
5 Correct 29 ms 600 KB Output is correct
6 Correct 29 ms 600 KB Output is correct
7 Correct 27 ms 600 KB Output is correct
8 Correct 29 ms 600 KB Output is correct
9 Correct 30 ms 628 KB Output is correct
10 Correct 29 ms 628 KB Output is correct
11 Correct 30 ms 628 KB Output is correct
12 Correct 29 ms 628 KB Output is correct
13 Correct 30 ms 628 KB Output is correct
14 Correct 52 ms 628 KB Output is correct
15 Correct 50 ms 644 KB Output is correct
16 Correct 8 ms 656 KB Output is correct
17 Correct 3 ms 656 KB Output is correct
18 Correct 3 ms 656 KB Output is correct
19 Correct 2 ms 656 KB Output is correct
20 Correct 2 ms 656 KB Output is correct
21 Correct 2 ms 656 KB Output is correct
22 Correct 3 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 756 ms 21368 KB Output is correct
2 Correct 817 ms 21368 KB Output is correct
3 Correct 269 ms 21368 KB Output is correct
4 Correct 770 ms 21368 KB Output is correct
5 Correct 296 ms 21368 KB Output is correct
6 Correct 195 ms 21368 KB Output is correct
7 Correct 270 ms 21368 KB Output is correct
8 Correct 249 ms 21368 KB Output is correct
9 Correct 238 ms 21368 KB Output is correct
10 Correct 241 ms 21368 KB Output is correct
11 Correct 234 ms 21368 KB Output is correct
12 Correct 266 ms 21368 KB Output is correct
13 Correct 788 ms 21368 KB Output is correct
14 Correct 765 ms 21368 KB Output is correct
15 Correct 181 ms 21368 KB Output is correct
16 Correct 692 ms 21368 KB Output is correct
17 Correct 273 ms 21368 KB Output is correct
18 Correct 193 ms 21368 KB Output is correct
19 Correct 233 ms 21384 KB Output is correct
20 Correct 285 ms 21384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 248 KB Output is correct
2 Correct 28 ms 356 KB Output is correct
3 Correct 32 ms 408 KB Output is correct
4 Correct 29 ms 408 KB Output is correct
5 Correct 29 ms 600 KB Output is correct
6 Correct 29 ms 600 KB Output is correct
7 Correct 27 ms 600 KB Output is correct
8 Correct 29 ms 600 KB Output is correct
9 Correct 30 ms 628 KB Output is correct
10 Correct 29 ms 628 KB Output is correct
11 Correct 30 ms 628 KB Output is correct
12 Correct 29 ms 628 KB Output is correct
13 Correct 30 ms 628 KB Output is correct
14 Correct 52 ms 628 KB Output is correct
15 Correct 50 ms 644 KB Output is correct
16 Correct 8 ms 656 KB Output is correct
17 Correct 3 ms 656 KB Output is correct
18 Correct 3 ms 656 KB Output is correct
19 Correct 2 ms 656 KB Output is correct
20 Correct 2 ms 656 KB Output is correct
21 Correct 2 ms 656 KB Output is correct
22 Correct 3 ms 656 KB Output is correct
23 Correct 756 ms 21368 KB Output is correct
24 Correct 817 ms 21368 KB Output is correct
25 Correct 269 ms 21368 KB Output is correct
26 Correct 770 ms 21368 KB Output is correct
27 Correct 296 ms 21368 KB Output is correct
28 Correct 195 ms 21368 KB Output is correct
29 Correct 270 ms 21368 KB Output is correct
30 Correct 249 ms 21368 KB Output is correct
31 Correct 238 ms 21368 KB Output is correct
32 Correct 241 ms 21368 KB Output is correct
33 Correct 234 ms 21368 KB Output is correct
34 Correct 266 ms 21368 KB Output is correct
35 Correct 788 ms 21368 KB Output is correct
36 Correct 765 ms 21368 KB Output is correct
37 Correct 181 ms 21368 KB Output is correct
38 Correct 692 ms 21368 KB Output is correct
39 Correct 273 ms 21368 KB Output is correct
40 Correct 193 ms 21368 KB Output is correct
41 Correct 233 ms 21384 KB Output is correct
42 Correct 285 ms 21384 KB Output is correct
43 Incorrect 739 ms 21384 KB Output isn't correct
44 Halted 0 ms 0 KB -