Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: anonymous
Problemset: สร้อยสลับสี (ยาวมาก)
Language: cpp
Time: 0.023 second
Submitted On: 2026-11-01 20:28:14
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int m,k;
ll n;
cin >> n >> m >> k;
vector<ll> x(m);
for(int i=0;i<m;i++) cin >> x[i];
ll ans = m;
for(int i=0;i<k;i++){
ll a;
int c;
cin >> a >> c;
ll cntl = upper_bound(x.begin(),x.end(), a) - x.begin();
int left = (cntl % 2 == 0 ? 1 : 0);
if(a == n) ans += (left != c);
else{
ll cntr = upper_bound(x.begin(),x.end(),a+1) - x.begin();
int valid = (cntr % 2 == 0 ? 1 : 0);
int g = (left != valid);
int h = (left != c) + (c != valid);
ans += h - g;
}
}
cout << ans;
}