Cod sursa(job #3277076)

Utilizator crina2120Arnautu Cristina-Crina crina2120 Data 15 februarie 2025 12:02:44
Problema Marbles Scor 60
Compilator cpp-64 Status done
Runda vs11_12_vine_oji_2025 Marime 0.93 kb
#include <bits/stdc++.h>
using namespace std;

ifstream fin("marbles.in");
ofstream fout("marbles.out");

int n, m;

struct marble
{
    int x, c;
} a[100003];

void Task1(int x, int y)
{
    int i;
    for (i = 1; i <= n; i++)
       if (a[i].x == x)
       {
           a[i].x = y;
           return ;
       }
}

void Task2(int x, int y)
{
    int i, fr[70] = {0}, maxx = 0;
    for (i = 1; i <= n; i++)
        if (a[i].c != 0 && a[i]. x >= x && a[i].x <= y)
        {
            fr[a[i].c]++;
            maxx = max(maxx, fr[a[i].c]);
        }
    fout << maxx << "\n";
}

int main()
{
    int i, c, x, y;
    fin >> n >> m;
    for (i = 1; i <= n; i++)
    {
        fin >> x >> y;
        a[i].x = x;
        a[i].c = y;
    }
    for (i = 1; i <= m; i++)
    {
        fin >> c >> x >> y;
        if (c == 0) Task1(x, x + y);
        else if (c == 1) Task2(x, y);
    }
    return 0;
}