Submission #1693730
Source Code Expand
#include <vector> #include <iostream> #include <assert.h> #include <algorithm> #define Unknown 2 #define No 0 #define Yes 1 int n, k, max; std::vector<unsigned char> v; std::vector<int> box; void init() { std::sort(box.begin(), box.end(), std::greater<int>()); max = box[0]; v.resize(max + 1, Unknown); for(int i = 0; i < n; i++) { int a = box[i]; // std::cout << a << "\n"; v[a] = Yes; for(int j = i + 1; j < n; j++) { const int diff = a - box[j]; // std::cout << a << " - " << box[j] << " = " << diff << "\n"; // std::cout << diff << "\n"; v[diff] = Yes; } } } bool configurable(int n) { if(max < n || n <= 0) return false; //std::cout << "? " << n << "\n"; if(v[n] != Unknown) { //std::cout << "P(" << n << ") = " << v[n] << "\n"; return v[n] == Yes; } v[n] = No; for(int x = 1; x <= max - n; x++) { if(configurable(n + x) && configurable(x)) { //std::cout << n << " = (" << (n + x) << " - " << x << ")\n"; v[n] = Yes; return true; } } return false; } int main() { std::cin >> n; std::cin >> k; box.resize(n); for(int i = 0; i < n; i++) { std::cin >> box[i]; } init(); if(configurable(k)) { std::cout << "POSSIBLE\n"; } else { std::cout << "IMPOSSIBLE\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Getting Difference |
User | harukamm |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1383 Byte |
Status | TLE |
Exec Time | 2113 ms |
Memory | 977152 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |
sample_04.txt | AC | 1 ms | 256 KB |
subtask_1_01.txt | MLE | 390 ms | 667776 KB |
subtask_1_02.txt | MLE | 253 ms | 405376 KB |
subtask_1_03.txt | TLE | 2113 ms | 977152 KB |
subtask_1_04.txt | TLE | 2106 ms | 701568 KB |
subtask_1_05.txt | AC | 1425 ms | 124544 KB |
subtask_1_06.txt | MLE | 713 ms | 976768 KB |
subtask_1_07.txt | TLE | 2113 ms | 977024 KB |
subtask_1_08.txt | TLE | 2104 ms | 164736 KB |
subtask_1_09.txt | TLE | 2113 ms | 976896 KB |
subtask_1_10.txt | TLE | 2113 ms | 977024 KB |
subtask_1_11.txt | TLE | 2104 ms | 251264 KB |