#include <algorithm> #include <cstdio> #include <cstdlib> #include <vector> using namespace std; #define YES do { printf("TAK\n"); exit(0); } while (0) #define NO do { printf("NIE\n"); exit(0); } while (0) struct job { int p, k, c; }; vector<job> jobs; vector<int> P, K; int n, m; int main() { scanf("%d %d", &n, &m); if (n <= m) { YES; } for (int i=0; i<n; i++) { int p, k, c; scanf("%d %d %d", &p, &k, &c); P.push_back(p); K.push_back(k); jobs.push_back({p, k, c}); } for (int p : P) { for (int k : K) { if (p >= k) { continue; } int cnt = 0; for (auto const& job : jobs) { cnt += max(0, job.c - max(0, job.k - k) - max(0, p - job.p)); } if ((k-p)*m < cnt) { NO; } } } YES; 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 44 45 46 47 | #include <algorithm> #include <cstdio> #include <cstdlib> #include <vector> using namespace std; #define YES do { printf("TAK\n"); exit(0); } while (0) #define NO do { printf("NIE\n"); exit(0); } while (0) struct job { int p, k, c; }; vector<job> jobs; vector<int> P, K; int n, m; int main() { scanf("%d %d", &n, &m); if (n <= m) { YES; } for (int i=0; i<n; i++) { int p, k, c; scanf("%d %d %d", &p, &k, &c); P.push_back(p); K.push_back(k); jobs.push_back({p, k, c}); } for (int p : P) { for (int k : K) { if (p >= k) { continue; } int cnt = 0; for (auto const& job : jobs) { cnt += max(0, job.c - max(0, job.k - k) - max(0, p - job.p)); } if ((k-p)*m < cnt) { NO; } } } YES; return 0; } |