Submission #694999

#TimeUsernameProblemLanguageResultExecution timeMemory
694999rainboySushi (JOI16_sushi)C11
5 / 100
53 ms5868 KiB
#include <stdio.h>

#define N	400000

int main() {
	static int aa[N];
	int n, q, i;

	scanf("%d%d", &n, &q);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	if (n <= 2000 && q <= 2000)
		while (q--) {
			int s, t, a, tmp;

			scanf("%d%d%d", &s, &t, &a), s--, t--;
			if (s <= t) {
				for (i = s; i <= t; i++)
					if (a < aa[i])
						tmp = a, a = aa[i], aa[i] = tmp;
			} else {
				for (i = s; i < n; i++)
					if (a < aa[i])
						tmp = a, a = aa[i], aa[i] = tmp;
				for (i = 0; i <= t; i++)
					if (a < aa[i])
						tmp = a, a = aa[i], aa[i] = tmp;
			}
			printf("%d\n", a);
		}
	return 0;
}

Compilation message (stderr)

sushi.c: In function 'main':
sushi.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d%d", &n, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~
sushi.c:11:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
sushi.c:16:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |    scanf("%d%d%d", &s, &t, &a), s--, t--;
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...