#include <bits/stdc++.h>
using namespace std;
vector <pair <pair <int, int>, int> > wektor;
int tablice[1000006];
int a,p,x,y,z;
bool prawda;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>a>>p;
	for (int i=0; i<a; i++){
		cin>>x>>y>>z;
		wektor.push_back(make_pair(make_pair(y,-x), z));
	}
	sort(wektor.begin(), wektor.end());
	for (int i=0; i<wektor.size(); i++){
		x=wektor[i].second;
		for (int j=-wektor[i].first.second; j<wektor[i].first.first && x>0; j++)
			if (tablice[j]<p){
				tablice[j]++;
				x--;
			}
		if (x>0){
			prawda=true;
			break;
		}
	}
	if (prawda==true)
		cout<<"NIE";
	else
		cout<<"TAK";
	
	return 0;
}
        | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <bits/stdc++.h> using namespace std; vector <pair <pair <int, int>, int> > wektor; int tablice[1000006]; int a,p,x,y,z; bool prawda; int main(){ ios_base::sync_with_stdio(0); cin>>a>>p; for (int i=0; i<a; i++){ cin>>x>>y>>z; wektor.push_back(make_pair(make_pair(y,-x), z)); } sort(wektor.begin(), wektor.end()); for (int i=0; i<wektor.size(); i++){ x=wektor[i].second; for (int j=-wektor[i].first.second; j<wektor[i].first.first && x>0; j++) if (tablice[j]<p){ tablice[j]++; x--; } if (x>0){ prawda=true; break; } } if (prawda==true) cout<<"NIE"; else cout<<"TAK"; return 0; } | 
 
            
         English
                    English