Submission

Status:
------TTTT

Score: 0

User: Jokul

Problemset: สร้อยสลับสี (ยาวมาก)

Language: c

Time: 1.095 second

Submitted On: 2025-03-13 15:45:47

#include <stdio.h>

int main() {
    long long int n, m, k, count = 0, sum = 0;
    scanf("%lld", &n);
    scanf("%lld", &m);
    scanf("%lld", &k);

    long long int a[m], c[m], d, e;
    a[0] = 0; // Initialize the first element
    c[0] = 1; // Initialize the first element of c

    // Loop from 0 to m-1 for correct indexing
    for (int i = 1; i < m; i++) {
        scanf("%lld", &a[i]);

        // Set c[i] based on whether i is odd or even
        if (i % 2 == 1) {
            c[i] = 0;
        } else {
            c[i] = 1;
        }
    }
 for(int x=0;x<k;x++){
    int pin = 1; // Initialize pin
    scanf("%lld", &d); // Use long long int for d
    scanf("%lld", &e); // Use long long int for e

    for (int i = 1; i < m; i++) {
        if (d >= a[i]) {
            pin++;
        }
    }

    // Logic to update sum based on conditions
    if (d == 1 && a[0] != 2) {
        sum = 0;
    } else if (d + 1 == a[pin] || d - 1 == a[pin - 1]) {
        sum++;
    } else {
        sum = sum; // This line is redundant
    }

    if (sum > 0 && e != (pin % 2)) {
        count++;
    }
    if (sum == 0 && e != (pin % 2)) {
        count+=2;
    } else if (e==(pin % 2)) {
        count=count;
    }
 }

    printf("%lld",count);

    return 0;

}