Submission #1005333
Source Code Expand
//絶対通らない //ビームサーチ #include <iostream> #include <vector> #include <queue> #include <cstdlib> #include <string> #include <algorithm> #define int long long using namespace std; int n; int a[20000]; int power[17]; void randomSuffle() { static bool used[20000] = {false}; static int b[20000]; int t; for (int i = 0; i < n; i++) { do { t = rand() % n; } while (used[t]); used[t] = true; b[i] = a[t]; } for (int i = 0; i < n; i++) { a[i] = b[i]; } } signed main() { int i, j, k, l; power[0] = 1; for (i = 1; i < 17; i++) { power[i] = power[i - 1] * 10; } cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } randomSuffle(); //ビームサーチ(商品1から順に選ぶ, 選ばない, をする) //「mod 10^k == x」のもののうち, width個だけを"適当に"採用。 //状態は:「金額」で持てばよい。 int WIDTH = 50 * 20000 / n; static vector<int> states[2][10]; int ans = 0; for (i = 0; i < 17; i++) { for (j = 0; j < 10; j++) states[0][j].clear(); states[0][0].push_back(0); for (j = 0; j < n; j++) { for (k = 0; k < 10; k++) { //mod 10^i == k for (l = 0; l < states[0][k].size(); l++) { int money = a[j] + states[0][k][l]; int mod = (money / power[i]) % 10; states[1][k].push_back(states[0][k][l]); states[1][mod].push_back(money); } } for (k = 0; k < 10; k++) { states[0][k].clear(); } for (k = 0; k < 10; k++) { for (l = 0; l < min(WIDTH, (int)states[1][k].size()); l++) { states[0][k].push_back(states[1][k][l]); } } for (k = 0; k < 10; k++) { states[1][k].clear(); } } for (j = 9; j >= 0; j--) { if (states[0][j].size() > 0) { break; } } ans += j; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Exact Payment |
User | startcpp |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1852 Byte |
Status | WA |
Exec Time | 2102 ms |
Memory | 768 KB |
Judge Result
Set Name | sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1500 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
All | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt, 01-52.txt, 01-53.txt, 01-54.txt, 01-55.txt, 01-56.txt, 01-57.txt, 01-58.txt, 01-59.txt, 01-60.txt, 01-61.txt, 01-62.txt, 01-63.txt, 01-64.txt, 01-65.txt, 01-66.txt, 01-67.txt, 01-68.txt, 01-69.txt, 01-70.txt, 01-71.txt, 01-72.txt, 01-73.txt, 01-74.txt, 01-75.txt, 01-76.txt, 01-77.txt, 01-78.txt, 01-79.txt, 01-80.txt, 01-81.txt, 01-82.txt, 01-83.txt, 01-84.txt, 01-85.txt, 01-86.txt, 01-87.txt, 01-88.txt, 01-89.txt, 01-90.txt, 01-91.txt, 01-92.txt, 01-93.txt, 01-94.txt, 01-95.txt, 01-96.txt, 01-97.txt, 01-98.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 3 ms | 256 KB |
01-02.txt | AC | 3 ms | 256 KB |
01-03.txt | AC | 3 ms | 256 KB |
01-04.txt | AC | 3 ms | 256 KB |
01-05.txt | AC | 3 ms | 256 KB |
01-06.txt | TLE | 2102 ms | 640 KB |
01-07.txt | TLE | 2102 ms | 640 KB |
01-08.txt | TLE | 2102 ms | 640 KB |
01-09.txt | TLE | 2102 ms | 640 KB |
01-10.txt | WA | 1826 ms | 640 KB |
01-11.txt | WA | 1948 ms | 640 KB |
01-12.txt | TLE | 2102 ms | 640 KB |
01-13.txt | TLE | 2102 ms | 640 KB |
01-14.txt | TLE | 2102 ms | 640 KB |
01-15.txt | TLE | 2102 ms | 640 KB |
01-16.txt | TLE | 2102 ms | 640 KB |
01-17.txt | TLE | 2047 ms | 640 KB |
01-18.txt | TLE | 2024 ms | 640 KB |
01-19.txt | TLE | 2102 ms | 640 KB |
01-20.txt | TLE | 2102 ms | 640 KB |
01-21.txt | TLE | 2046 ms | 640 KB |
01-22.txt | TLE | 2019 ms | 640 KB |
01-23.txt | TLE | 2021 ms | 640 KB |
01-24.txt | WA | 1963 ms | 640 KB |
01-25.txt | WA | 1996 ms | 640 KB |
01-26.txt | TLE | 2036 ms | 640 KB |
01-27.txt | TLE | 2102 ms | 640 KB |
01-28.txt | WA | 1981 ms | 640 KB |
01-29.txt | WA | 1980 ms | 640 KB |
01-30.txt | TLE | 2042 ms | 640 KB |
01-31.txt | TLE | 2016 ms | 640 KB |
01-32.txt | WA | 1967 ms | 640 KB |
01-33.txt | WA | 1996 ms | 640 KB |
01-34.txt | TLE | 2028 ms | 640 KB |
01-35.txt | TLE | 2061 ms | 640 KB |
01-36.txt | WA | 1991 ms | 640 KB |
01-37.txt | WA | 1986 ms | 640 KB |
01-38.txt | TLE | 2019 ms | 640 KB |
01-39.txt | TLE | 2038 ms | 640 KB |
01-40.txt | TLE | 2026 ms | 640 KB |
01-41.txt | TLE | 2059 ms | 640 KB |
01-42.txt | TLE | 2036 ms | 640 KB |
01-43.txt | TLE | 2028 ms | 640 KB |
01-44.txt | TLE | 2102 ms | 640 KB |
01-45.txt | TLE | 2102 ms | 640 KB |
01-46.txt | TLE | 2041 ms | 640 KB |
01-47.txt | TLE | 2031 ms | 640 KB |
01-48.txt | TLE | 2040 ms | 640 KB |
01-49.txt | WA | 1962 ms | 640 KB |
01-50.txt | WA | 1985 ms | 768 KB |
01-51.txt | WA | 1962 ms | 768 KB |
01-52.txt | TLE | 2060 ms | 640 KB |
01-53.txt | TLE | 2026 ms | 640 KB |
01-54.txt | TLE | 2023 ms | 768 KB |
01-55.txt | WA | 1968 ms | 640 KB |
01-56.txt | WA | 1960 ms | 640 KB |
01-57.txt | WA | 1983 ms | 640 KB |
01-58.txt | TLE | 2102 ms | 640 KB |
01-59.txt | TLE | 2102 ms | 640 KB |
01-60.txt | TLE | 2102 ms | 640 KB |
01-61.txt | TLE | 2102 ms | 640 KB |
01-62.txt | TLE | 2102 ms | 640 KB |
01-63.txt | TLE | 2102 ms | 640 KB |
01-64.txt | TLE | 2089 ms | 640 KB |
01-65.txt | TLE | 2102 ms | 640 KB |
01-66.txt | WA | 546 ms | 640 KB |
01-67.txt | WA | 1106 ms | 640 KB |
01-68.txt | WA | 1292 ms | 640 KB |
01-69.txt | WA | 1301 ms | 640 KB |
01-70.txt | WA | 1259 ms | 640 KB |
01-71.txt | WA | 858 ms | 640 KB |
01-72.txt | WA | 825 ms | 640 KB |
01-73.txt | WA | 923 ms | 640 KB |
01-74.txt | WA | 860 ms | 640 KB |
01-75.txt | WA | 935 ms | 640 KB |
01-76.txt | WA | 833 ms | 640 KB |
01-77.txt | WA | 1447 ms | 640 KB |
01-78.txt | WA | 966 ms | 640 KB |
01-79.txt | WA | 987 ms | 640 KB |
01-80.txt | WA | 951 ms | 640 KB |
01-81.txt | WA | 984 ms | 768 KB |
01-82.txt | WA | 924 ms | 640 KB |
01-83.txt | WA | 1007 ms | 640 KB |
01-84.txt | WA | 908 ms | 640 KB |
01-85.txt | WA | 983 ms | 640 KB |
01-86.txt | WA | 984 ms | 640 KB |
01-87.txt | WA | 1065 ms | 640 KB |
01-88.txt | WA | 917 ms | 640 KB |
01-89.txt | WA | 1074 ms | 640 KB |
01-90.txt | WA | 1592 ms | 640 KB |
01-91.txt | WA | 1072 ms | 640 KB |
01-92.txt | WA | 1094 ms | 640 KB |
01-93.txt | WA | 1121 ms | 640 KB |
01-94.txt | WA | 1099 ms | 640 KB |
01-95.txt | WA | 1196 ms | 640 KB |
01-96.txt | WA | 1766 ms | 640 KB |
01-97.txt | WA | 1089 ms | 640 KB |
01-98.txt | WA | 1215 ms | 640 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | AC | 3 ms | 256 KB |