Submission #994293
Source Code Expand
#include <algorithm> #include <iostream> using namespace std; const int N = (int) 2e5 + 7; int sum[N]; int a[N]; int f[N]; int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n - 1; ++i) cin >> a[i]; int m; cin >> m; for (int i = 0; i < n - 1; ++i) sum[i + 1] = sum[i] + a[i]; for (int zzz = 0; zzz < m; ++zzz) { cin >> a[n - 1]; sum[n] = sum[n - 1] + a[n - 1]; f[n - 1] = -a[n - 1]; int best = f[n - 1] + sum[n - 1]; for (int i = n - 2; i > 0; --i) { f[i] = sum[i] - best; best = min(best, f[i] + sum[i]); } cout << f[1] + a[0] << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | H - Tokaido |
User | dnk |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 721 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 2688 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | 0 / 900 | ||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
dataset1 | sample-01.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 |
dataset2 | 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, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 16 ms | 2560 KB |
01-02.txt | AC | 3 ms | 256 KB |
01-03.txt | AC | 3 ms | 256 KB |
01-04.txt | AC | 10 ms | 1408 KB |
01-05.txt | AC | 16 ms | 2560 KB |
01-06.txt | AC | 16 ms | 2560 KB |
01-07.txt | AC | 7 ms | 896 KB |
01-08.txt | AC | 17 ms | 2560 KB |
01-09.txt | AC | 17 ms | 2560 KB |
01-10.txt | AC | 3 ms | 256 KB |
01-11.txt | AC | 5 ms | 768 KB |
01-12.txt | AC | 17 ms | 2560 KB |
01-13.txt | AC | 17 ms | 2560 KB |
01-14.txt | AC | 17 ms | 2560 KB |
01-15.txt | AC | 17 ms | 2560 KB |
01-16.txt | AC | 17 ms | 2560 KB |
01-17.txt | AC | 17 ms | 2560 KB |
01-18.txt | AC | 17 ms | 2560 KB |
01-19.txt | AC | 17 ms | 2560 KB |
02-01.txt | AC | 1451 ms | 896 KB |
02-02.txt | TLE | 2102 ms | 2688 KB |
02-03.txt | TLE | 2102 ms | 2560 KB |
02-04.txt | TLE | 2102 ms | 2560 KB |
02-05.txt | AC | 1244 ms | 1024 KB |
02-06.txt | TLE | 2102 ms | 2688 KB |
02-07.txt | TLE | 2102 ms | 2560 KB |
02-08.txt | AC | 895 ms | 1536 KB |
02-09.txt | AC | 1252 ms | 1536 KB |
02-10.txt | TLE | 2102 ms | 1536 KB |
02-11.txt | TLE | 2102 ms | 2688 KB |
02-12.txt | TLE | 2102 ms | 2560 KB |
02-13.txt | TLE | 2102 ms | 2688 KB |
02-14.txt | TLE | 2104 ms | 2688 KB |
02-15.txt | TLE | 2102 ms | 2688 KB |
02-16.txt | TLE | 2102 ms | 2688 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | AC | 3 ms | 256 KB |