#include<cstdio>
#include<algorithm>
std::pair< std::pair<int, int>, int>p[102];
bool t[102][1000003];
int j,k;
bool c=true;
int main()
{
int n,m,a,b,c;
scanf("%d%d", &n, &m);
for(int i=0; i<n; i++)
{
scanf("%d%d%d", &a, &b, &c);
p[i].first.first=b;
p[i].first.second=a;
p[i].second=c;
}
std::sort(p, p+n);
for(int i=0; i<n; i++)
{
for(int y=0; y<m; y++)
{
k=p[i].first.first;
j=p[i].first.second;
for(j; j<k; j++)if(!t[y][j]&&p[i].second>0)
{
p[i].second--;
t[y][j]=1;
if(p[i].second==0)break;
}
}
if(p[i].second>0)
{
c=false;
break;
}
}
if(c)printf("TAK\n");
else printf("NIE\n");
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 34 35 36 37 38 39 40 41 42 43 | #include<cstdio> #include<algorithm> std::pair< std::pair<int, int>, int>p[102]; bool t[102][1000003]; int j,k; bool c=true; int main() { int n,m,a,b,c; scanf("%d%d", &n, &m); for(int i=0; i<n; i++) { scanf("%d%d%d", &a, &b, &c); p[i].first.first=b; p[i].first.second=a; p[i].second=c; } std::sort(p, p+n); for(int i=0; i<n; i++) { for(int y=0; y<m; y++) { k=p[i].first.first; j=p[i].first.second; for(j; j<k; j++)if(!t[y][j]&&p[i].second>0) { p[i].second--; t[y][j]=1; if(p[i].second==0)break; } } if(p[i].second>0) { c=false; break; } } if(c)printf("TAK\n"); else printf("NIE\n"); return 0; } |
English