Submission #2705882
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int Nmax = 2e4 + 5; typedef long long ll; typedef pair<ll, ll> Pair; vector<Pair> v, w; vector<ll> A; ll p10[20]; vector<Pair> best(vector<Pair> v) { vector<Pair> ans; sort(v.begin(), v.end()); ll l = -1, r = -1; for(auto it : v) if(it.first <= r) r = max(r, it.second); else { ans.push_back({l, r}); l = it.first; r = it.second; } ans.push_back({l, r}); return ans; } bool solve(int p, int c) { w.clear(); w.push_back({p10[p] * c, p10[p] * (c+1) - 1}); ll x, y; for(auto val : A) { v.clear(); for(auto seg : w) { x = seg.first; y = seg.second; v.push_back({x, y}); val %= p10[p+1]; x -= val; y -= val; if(x<=0 && y>=0) return 1; if(x<0 && y<0) x += p10[p+1], y += p10[p+1]; v.push_back({x, y}); } w = best(v); } return 0; } int main() { // freopen("input", "r", stdin); // freopen("output", "w", stdout); cin.sync_with_stdio(false); int i, c, ans = 0, n; cin >> n; A.resize(n); for(auto &it : A) cin >> it; p10[0] = 1; for(i=1; i<=17; ++i) p10[i] = (ll) p10[i-1] * 10; for(i=0; i<17; ++i) for(c=9; c; --c) if(solve(i, c)) { ans += c; break; } cout << ans << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Exact Payment |
User | Alexa2001 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1635 Byte |
Status | TLE |
Exec Time | 2106 ms |
Memory | 687552 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, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 1 ms | 256 KB |
01-06.txt | TLE | 2105 ms | 659084 KB |
01-07.txt | TLE | 2105 ms | 656716 KB |
01-08.txt | TLE | 2105 ms | 658156 KB |
01-09.txt | TLE | 2105 ms | 656204 KB |
01-10.txt | TLE | 2106 ms | 676644 KB |
01-11.txt | TLE | 2106 ms | 687008 KB |
01-12.txt | TLE | 2106 ms | 624960 KB |
01-13.txt | TLE | 2106 ms | 687552 KB |
01-14.txt | TLE | 2106 ms | 658052 KB |
01-15.txt | TLE | 2105 ms | 657492 KB |
01-16.txt | TLE | 2105 ms | 655888 KB |
01-17.txt | TLE | 2105 ms | 655048 KB |
01-18.txt | TLE | 2105 ms | 652952 KB |
01-19.txt | TLE | 2104 ms | 44152 KB |
01-20.txt | TLE | 2105 ms | 314796 KB |
01-21.txt | TLE | 2105 ms | 655000 KB |
01-22.txt | TLE | 2105 ms | 654496 KB |
01-23.txt | TLE | 2106 ms | 686916 KB |
01-24.txt | TLE | 2106 ms | 567056 KB |
01-25.txt | TLE | 2105 ms | 274612 KB |
01-26.txt | TLE | 2105 ms | 653872 KB |
01-27.txt | TLE | 2105 ms | 682804 KB |
01-28.txt | TLE | 2106 ms | 684692 KB |
01-29.txt | TLE | 2104 ms | 221532 KB |
01-30.txt | TLE | 2105 ms | 654012 KB |
01-31.txt | TLE | 2105 ms | 653148 KB |
01-32.txt | TLE | 2106 ms | 618748 KB |
01-33.txt | TLE | 2105 ms | 260944 KB |
01-34.txt | TLE | 2105 ms | 652932 KB |
01-35.txt | TLE | 2105 ms | 653080 KB |
01-36.txt | TLE | 2106 ms | 622732 KB |
01-37.txt | TLE | 2106 ms | 676568 KB |
01-38.txt | TLE | 2105 ms | 681172 KB |
01-39.txt | TLE | 2106 ms | 684936 KB |
01-40.txt | TLE | 2105 ms | 653844 KB |
01-41.txt | TLE | 2106 ms | 687296 KB |
01-42.txt | TLE | 2106 ms | 684168 KB |
01-43.txt | TLE | 2106 ms | 686640 KB |
01-44.txt | TLE | 2105 ms | 654804 KB |
01-45.txt | TLE | 2105 ms | 653540 KB |
01-46.txt | TLE | 2105 ms | 652408 KB |
01-47.txt | TLE | 2105 ms | 654060 KB |
01-48.txt | TLE | 2105 ms | 653864 KB |
01-49.txt | TLE | 2106 ms | 684400 KB |
01-50.txt | TLE | 2106 ms | 685032 KB |
01-51.txt | TLE | 2105 ms | 683192 KB |
01-52.txt | TLE | 2106 ms | 686812 KB |
01-53.txt | TLE | 2106 ms | 683716 KB |
01-54.txt | TLE | 2106 ms | 683976 KB |
01-55.txt | TLE | 2106 ms | 681044 KB |
01-56.txt | TLE | 2106 ms | 678096 KB |
01-57.txt | TLE | 2106 ms | 681912 KB |
01-58.txt | TLE | 2105 ms | 653712 KB |
01-59.txt | TLE | 2105 ms | 653244 KB |
01-60.txt | TLE | 2106 ms | 687384 KB |
01-61.txt | TLE | 2105 ms | 654736 KB |
01-62.txt | TLE | 2105 ms | 653776 KB |
01-63.txt | TLE | 2106 ms | 683612 KB |
01-64.txt | TLE | 2105 ms | 652924 KB |
01-65.txt | TLE | 2105 ms | 651628 KB |
01-66.txt | TLE | 2103 ms | 1476 KB |
01-67.txt | TLE | 2103 ms | 3356 KB |
01-68.txt | TLE | 2103 ms | 4040 KB |
01-69.txt | TLE | 2104 ms | 6624 KB |
01-70.txt | TLE | 2103 ms | 3712 KB |
01-71.txt | TLE | 2103 ms | 640 KB |
01-72.txt | TLE | 2103 ms | 4068 KB |
01-73.txt | TLE | 2103 ms | 640 KB |
01-74.txt | TLE | 2103 ms | 512 KB |
01-75.txt | TLE | 2103 ms | 1464 KB |
01-76.txt | TLE | 2103 ms | 640 KB |
01-77.txt | TLE | 2103 ms | 2180 KB |
01-78.txt | TLE | 2103 ms | 848 KB |
01-79.txt | TLE | 2103 ms | 3096 KB |
01-80.txt | TLE | 2103 ms | 684 KB |
01-81.txt | TLE | 2103 ms | 848 KB |
01-82.txt | TLE | 2103 ms | 864 KB |
01-83.txt | TLE | 2103 ms | 872 KB |
01-84.txt | TLE | 2103 ms | 640 KB |
01-85.txt | TLE | 2103 ms | 860 KB |
01-86.txt | TLE | 2103 ms | 640 KB |
01-87.txt | TLE | 2103 ms | 640 KB |
01-88.txt | TLE | 2103 ms | 1048 KB |
01-89.txt | TLE | 2103 ms | 872 KB |
01-90.txt | TLE | 2104 ms | 42764 KB |
01-91.txt | TLE | 2103 ms | 860 KB |
01-92.txt | TLE | 2103 ms | 1092 KB |
01-93.txt | TLE | 2103 ms | 640 KB |
01-94.txt | TLE | 2103 ms | 640 KB |
01-95.txt | TLE | 2103 ms | 1040 KB |
01-96.txt | TLE | 2105 ms | 59200 KB |
01-97.txt | TLE | 2103 ms | 920 KB |
01-98.txt | TLE | 2103 ms | 868 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |