답안 #100905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100905 2019-03-15T04:40:34 Z autumn_eel Sushi (JOI16_sushi) C++14
20 / 100
122 ms 6656 KB
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int x[3000];
int main(){
	int n,q;cin>>n>>q;
	if(n<=2000&&q<=2000){
		rep(i,n){
			scanf("%d",&x[i]);
		}
		rep(i,q){
			int s,t,p;scanf("%d%d%d",&s,&t,&p);s--;t--;
			int pos=s;
			while(1){
				if(x[pos]>p){
					swap(x[pos],p);
				}
				if(pos==t)break;
				(pos+=1)%=n;
			}
			printf("%d\n",p);
		}
		return 0;
	}
	priority_queue<int>que;
	rep(i,n){
		int x;scanf("%d",&x);
		que.push(x);
	}
	rep(i,q){
		int s,t,p;scanf("%d%d%d",&s,&t,&p);
		que.push(p);
		printf("%d\n",que.top());
		que.pop();
	}
}

Compilation message

sushi.cpp: In function 'int main()':
sushi.cpp:12:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&x[i]);
    ~~~~~^~~~~~~~~~~~
sushi.cpp:15:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int s,t,p;scanf("%d%d%d",&s,&t,&p);s--;t--;
              ~~~~~^~~~~~~~~~~~~~~~~~~
sushi.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x;scanf("%d",&x);
         ~~~~~^~~~~~~~~
sushi.cpp:34:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int s,t,p;scanf("%d%d%d",&s,&t,&p);
             ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 384 KB Output is correct
2 Correct 23 ms 384 KB Output is correct
3 Correct 26 ms 384 KB Output is correct
4 Correct 23 ms 384 KB Output is correct
5 Correct 22 ms 384 KB Output is correct
6 Correct 24 ms 384 KB Output is correct
7 Correct 23 ms 384 KB Output is correct
8 Correct 22 ms 384 KB Output is correct
9 Correct 24 ms 384 KB Output is correct
10 Correct 25 ms 420 KB Output is correct
11 Correct 24 ms 384 KB Output is correct
12 Correct 25 ms 384 KB Output is correct
13 Correct 28 ms 504 KB Output is correct
14 Correct 43 ms 504 KB Output is correct
15 Correct 40 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 2544 KB Output is correct
2 Correct 80 ms 2540 KB Output is correct
3 Correct 51 ms 2668 KB Output is correct
4 Correct 96 ms 2540 KB Output is correct
5 Correct 74 ms 2540 KB Output is correct
6 Correct 84 ms 2540 KB Output is correct
7 Correct 84 ms 2536 KB Output is correct
8 Correct 95 ms 2556 KB Output is correct
9 Correct 73 ms 2536 KB Output is correct
10 Correct 65 ms 2536 KB Output is correct
11 Correct 50 ms 2540 KB Output is correct
12 Correct 84 ms 2540 KB Output is correct
13 Correct 108 ms 2540 KB Output is correct
14 Correct 89 ms 2540 KB Output is correct
15 Correct 49 ms 2540 KB Output is correct
16 Correct 91 ms 2536 KB Output is correct
17 Correct 87 ms 2536 KB Output is correct
18 Correct 92 ms 2568 KB Output is correct
19 Correct 122 ms 2532 KB Output is correct
20 Correct 118 ms 2516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 384 KB Output is correct
2 Correct 23 ms 384 KB Output is correct
3 Correct 26 ms 384 KB Output is correct
4 Correct 23 ms 384 KB Output is correct
5 Correct 22 ms 384 KB Output is correct
6 Correct 24 ms 384 KB Output is correct
7 Correct 23 ms 384 KB Output is correct
8 Correct 22 ms 384 KB Output is correct
9 Correct 24 ms 384 KB Output is correct
10 Correct 25 ms 420 KB Output is correct
11 Correct 24 ms 384 KB Output is correct
12 Correct 25 ms 384 KB Output is correct
13 Correct 28 ms 504 KB Output is correct
14 Correct 43 ms 504 KB Output is correct
15 Correct 40 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 96 ms 2544 KB Output is correct
24 Correct 80 ms 2540 KB Output is correct
25 Correct 51 ms 2668 KB Output is correct
26 Correct 96 ms 2540 KB Output is correct
27 Correct 74 ms 2540 KB Output is correct
28 Correct 84 ms 2540 KB Output is correct
29 Correct 84 ms 2536 KB Output is correct
30 Correct 95 ms 2556 KB Output is correct
31 Correct 73 ms 2536 KB Output is correct
32 Correct 65 ms 2536 KB Output is correct
33 Correct 50 ms 2540 KB Output is correct
34 Correct 84 ms 2540 KB Output is correct
35 Correct 108 ms 2540 KB Output is correct
36 Correct 89 ms 2540 KB Output is correct
37 Correct 49 ms 2540 KB Output is correct
38 Correct 91 ms 2536 KB Output is correct
39 Correct 87 ms 2536 KB Output is correct
40 Correct 92 ms 2568 KB Output is correct
41 Correct 122 ms 2532 KB Output is correct
42 Correct 118 ms 2516 KB Output is correct
43 Incorrect 108 ms 6656 KB Output isn't correct
44 Halted 0 ms 0 KB -