# include <iostream>                                                            
using namespace std;                                                            
                                                                                
main()                                                                          
{                                                                               
    int n, m, p, k, c;                                                          
    cin >> n;                                                                   
    cin >> m;                                                                   
    int* task = new int[(n)];                                                   
    int* procesor = new int[(m)];                                               
    int* time = new int[(n)];                                                   
    int* start = new int[(n)];                                                  
    int* end = new int[(n)];                                                    
    int* death = new int[(n)];                                                  
    int i, j, g, h;                                                             
    int zajete=0;                                                               
    int bigest=0, efect=0, slt=1000000, sld=1000000;                            
                                                                                
    j=0;                                                                        
                                                                                
    for(i=0; i<n; i++)                                                          
    {                                                                           
        cin >> start[i];                                                        
        cin >> end[i];                                                          
        cin >> time[i];                                                         
        procesor[i]=0;                                                          
        task[i]=0;                                                              
    }                                                                           
                                                                                
    for(i=0; i<n; i++)                                                          
    {                                                                           
        if (end[i]>bigest)                                                      
        {                                                                       
            bigest=end[i];                                                      
        }                                                                       
    }                                                                           
                                                                                
    for(i=0; i<bigest; i++)                                                     
    {                                                                           
        for (h=0; h<m; h++)                                                     
                    {                                                           
                        if (procesor[h]>0)                                      
                        {                                                       
                            procesor[h]=0;                                      
                            time[h]=time[h]-1;                                  
                            if (time[h]==0)                                     
                            {                                                   
                                zajete=zajete-1;                                
                                task[h]=1;                                      
                            }                                                   
                        }                                                       
                    }                                                           
        for (h=0; h<n; h++)                                                     
        {                                                                       
        if(end[h]==0)                                                           
        {                                                                       
            if(task[h]==0)                                                      
            {                                                                   
                efect=2;                                                                                                        
            }                                                                   
        }                                                                       
                                                                                
        death[h]=end[h];                                                        
                                                                                
        if(time[h]>0)                                                           
        {                                                                       
            death[h]= death[h]-time[h];                                         
        }                                                                       
        if(start[h]>0)                                                          
        {                                                                       
            death[h]= death[h]-start[h];                                        
        }                                                                       
            }                                                                   
                                                                                
        for(g=0; g<n; g++)                                                      
        {                                                                       
            if ((death[g]==0)&&(task[h]==0))                                    
            {                                                                   
                j=j+1;                                                          
            }                                                                   
            if (death[g]<0)                                                     
            {                                                                   
                efect=2;                                                                                                         
            }                                                                   
        }                                                                       
                                                                                
        if (j>m)                                                                
        {                                                                       
            efect=2;                                                            
        }                                                                       
        slt=1000000;                                                            
        for(g=0; g<n; g++)                                                      
        {                                                                       
            if ((start[g]<slt)&&(task[g]==0))                                   
            {                                                                   
                slt=start[g];                                                   
            }                                                                   
        }                                                                       
        sld=1000000;                                                            
        for(g=0; g<n; g++)                                                      
        {                                                                       
            if (start[g]==slt)                                                  
            {                                                                   
                if(death[g]<sld)                                                
                {                                                               
                    sld=death[g];                                               
                }                                                               
            }                                                                   
        }                                                                       
        for(g=0; g<n; g++)                                                      
        {                                                                       
            if (start[g]==slt)                                                  
            {                                                                   
                if (death[g]==sld)                                              
                {                                                               
                    for (h=0; h<m; h++)                                         
                    {                                                           
                        if (procesor[h]==0)                                     
                        {                                                       
                        procesor[h]=time[g];                                    
                        zajete=zajete+1;                                 
                        h=m;                                                    
                        }                                                       
                    }                                                           
                }                                                               
            }                                                                   
                                                                                
            end[g]=end[g]-1;   
			if(start[g]>0)							                                          
            {
				start[g]=start[g]-1; 
			}
                                                                                
        }                                                                       
        if (j>zajete)                                                           
        {                                                                       
            efect=2;                                                                                                           
        }                                                                       
                                                                                
        j=0;                                                                    
        if (efect==2)                                                           
        {                                                                       
            cout<<"NIE";                                                        
            i=n;                                                                
        }                                                                       
        h=1;                                                                    
        for(g=0; g<n; g++)                                                      
        {                                                                       
            if (task[g]==0)                                                     
            {                                                                   
                h=0;                                                            
            }                                                                   
        }                                                                       
        if(h=1)                                                                 
        {                                                                       
            i=bigest;                                                           
        }                                                                       
    }                                                                           
    if (efect==0)                                                               
    cout<<"TAK";                                                                
}                                                                               
        | 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | # include <iostream> using namespace std; main() { int n, m, p, k, c; cin >> n; cin >> m; int* task = new int[(n)]; int* procesor = new int[(m)]; int* time = new int[(n)]; int* start = new int[(n)]; int* end = new int[(n)]; int* death = new int[(n)]; int i, j, g, h; int zajete=0; int bigest=0, efect=0, slt=1000000, sld=1000000; j=0; for(i=0; i<n; i++) { cin >> start[i]; cin >> end[i]; cin >> time[i]; procesor[i]=0; task[i]=0; } for(i=0; i<n; i++) { if (end[i]>bigest) { bigest=end[i]; } } for(i=0; i<bigest; i++) { for (h=0; h<m; h++) { if (procesor[h]>0) { procesor[h]=0; time[h]=time[h]-1; if (time[h]==0) { zajete=zajete-1; task[h]=1; } } } for (h=0; h<n; h++) { if(end[h]==0) { if(task[h]==0) { efect=2; } } death[h]=end[h]; if(time[h]>0) { death[h]= death[h]-time[h]; } if(start[h]>0) { death[h]= death[h]-start[h]; } } for(g=0; g<n; g++) { if ((death[g]==0)&&(task[h]==0)) { j=j+1; } if (death[g]<0) { efect=2; } } if (j>m) { efect=2; } slt=1000000; for(g=0; g<n; g++) { if ((start[g]<slt)&&(task[g]==0)) { slt=start[g]; } } sld=1000000; for(g=0; g<n; g++) { if (start[g]==slt) { if(death[g]<sld) { sld=death[g]; } } } for(g=0; g<n; g++) { if (start[g]==slt) { if (death[g]==sld) { for (h=0; h<m; h++) { if (procesor[h]==0) { procesor[h]=time[g]; zajete=zajete+1; h=m; } } } } end[g]=end[g]-1; if(start[g]>0) { start[g]=start[g]-1; } } if (j>zajete) { efect=2; } j=0; if (efect==2) { cout<<"NIE"; i=n; } h=1; for(g=0; g<n; g++) { if (task[g]==0) { h=0; } } if(h=1) { i=bigest; } } if (efect==0) cout<<"TAK"; } | 
 
            
         English
                    English