Submission #833344

# Submission time Handle Problem Language Result Execution time Memory
833344 2023-08-22T04:45:17 Z vjudge1 Exam (eJOI20_exam) C++17
12 / 100
16 ms 1876 KB
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	int a[n+5];
	int b[n+5];
	bool sub2 = true;
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=n; i++){
		cin>>b[i];
		if(i > 1 && b[i] != b[1]) sub2 = false;
	}
	vector<int> id;
	int on[n+5];
	memset(on, 0, sizeof(on));
	for(int i=1; i<=n; i++){
		if(a[i] == b[i]) id.push_back(i);
	}
	for(auto z: id){
		if(!on[z]){
			on[z] = 1;
			int x = z+1;
			while(x <= n && a[x] <= a[z] && on[x] == 0){
				on[x] = 1;
				x++;
			}
			x = z-1;
			while(x >= 1 && a[x] <= a[z] && on[x] == 0){
				on[x] = 1;
				x--;
			}
		}
	}	
	int cnt = 0;
	for(int i=1; i<=n; i++){
		if(on[i]) cnt++;
	}
	cout<<cnt<<endl; 
	return 0;
}

Compilation message

exam.cpp: In function 'int main()':
exam.cpp:11:7: warning: variable 'sub2' set but not used [-Wunused-but-set-variable]
   11 |  bool sub2 = true;
      |       ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 11 ms 1364 KB Output is correct
4 Correct 8 ms 1480 KB Output is correct
5 Correct 16 ms 1476 KB Output is correct
6 Correct 9 ms 1876 KB Output is correct
7 Correct 10 ms 1480 KB Output is correct
8 Correct 15 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -