답안 #890417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890417 2023-12-21T06:55:45 Z Hovhannes1234 Simple game (IZhO17_game) C++17
22 / 100
158 ms 2140 KB
#include <bits/stdc++.h>
using namespace std;

const int N=1e5+5;
int a[N], b[N];
int n,m;

void precalc(){
	for(int i=0; i<n-1; i++){
		for(int j = min(a[i], a[i+1]); j <= max(a[i], a[i+1]); j++){
			b[j]++;
		}
		
	}
}

int main() {
	cin>>n>>m;
	int mx=-1;
	for(int i=0; i<n; i++){cin>>a[i]; mx=max(mx, a[i]);}
	if(n <= 1000 && m<=1000){
		for(int i=0; i<m; i++){
			int q;
			cin>>q;
			if(q==2){
				long long anss=0;
				int h;
				cin>>h;
				for(int i=0; i<n-1; i++){
					if(a[i] >= h && a[i+1] <= h)anss++;
					else if(a[i] <= h && a[i+1] >= h)anss++;
				}
				cout<<anss<<endl;
			}else{
				int c,d;
				cin>>c>>d;
				a[c-1] = d;
			}
		}
		return 0;
	}
	precalc();
//	for(int i=1; i<=mx; i++)cout<<b[i]<<" ";
//	cout<<endl;
	for(int i=0; i<m; i++){
		int q;
		cin>>q;
		if(q==2){
			int h;
			cin>>h;
			cout<<b[h]<<"\n";
		}else{
			int a,b;
			cin>>a>>b;
		}
	}
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Correct 3 ms 456 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Correct 3 ms 456 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 158 ms 1980 KB Output is correct
9 Runtime error 22 ms 2140 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Correct 3 ms 456 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 158 ms 1980 KB Output is correct
9 Runtime error 22 ms 2140 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -