Submission #1337578
Source Code Expand
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int64 s[N], dp[N];
int main() {
int n, m;
scanf("%d", &n);
for (int i = 0; i < n - 1; ++i) {
scanf("%d", &a[i]);
}
scanf("%d", &m);
assert(m == 1);
scanf("%d", &a[n - 1]);
s[0] = a[0];
for (int i = 1; i < n; ++i) {
s[i] = s[i - 1] + a[i];
}
dp[n - 1] = 0;
int64 best = s[n - 2] - a[n - 1] + dp[n - 1];
for (int i = n - 2; i >= 1; --i) {
dp[i] = s[i] - best;
best = min(best, s[i - 1] - a[i] + dp[i]);
}
printf("%lld\n", dp[1] + a[0] - a[1]);
return 0;
}
Submission Info
Submission Time |
|
Task |
H - Tokaido |
User |
cuiaoxiang |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1505 Byte |
Status |
RE |
Exec Time |
112 ms |
Memory |
4096 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:47:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:49:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^
./Main.cpp:51:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &m);
^
./Main.cpp:53:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[n - 1]);
^
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, sample-01.txt, sample-02.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
17 ms |
4096 KB |
01-02.txt |
AC |
1 ms |
256 KB |
01-03.txt |
AC |
1 ms |
256 KB |
01-04.txt |
AC |
9 ms |
2048 KB |
01-05.txt |
AC |
17 ms |
4096 KB |
01-06.txt |
AC |
17 ms |
4096 KB |
01-07.txt |
AC |
6 ms |
1408 KB |
01-08.txt |
AC |
18 ms |
4096 KB |
01-09.txt |
AC |
18 ms |
4096 KB |
01-10.txt |
AC |
1 ms |
256 KB |
01-11.txt |
AC |
4 ms |
1024 KB |
01-12.txt |
AC |
17 ms |
3968 KB |
01-13.txt |
AC |
18 ms |
4096 KB |
01-14.txt |
AC |
18 ms |
4096 KB |
01-15.txt |
AC |
18 ms |
4096 KB |
01-16.txt |
AC |
17 ms |
4096 KB |
01-17.txt |
AC |
17 ms |
4096 KB |
01-18.txt |
AC |
17 ms |
4096 KB |
01-19.txt |
AC |
17 ms |
4096 KB |
02-01.txt |
RE |
99 ms |
384 KB |
02-02.txt |
RE |
110 ms |
1024 KB |
02-03.txt |
RE |
111 ms |
1024 KB |
02-04.txt |
RE |
110 ms |
1024 KB |
02-05.txt |
RE |
97 ms |
256 KB |
02-06.txt |
RE |
110 ms |
1024 KB |
02-07.txt |
RE |
112 ms |
1024 KB |
02-08.txt |
RE |
95 ms |
256 KB |
02-09.txt |
RE |
97 ms |
256 KB |
02-10.txt |
RE |
104 ms |
640 KB |
02-11.txt |
RE |
112 ms |
1024 KB |
02-12.txt |
RE |
111 ms |
1024 KB |
02-13.txt |
RE |
112 ms |
1024 KB |
02-14.txt |
RE |
110 ms |
1024 KB |
02-15.txt |
RE |
109 ms |
1024 KB |
02-16.txt |
RE |
109 ms |
1024 KB |
sample-01.txt |
AC |
1 ms |
256 KB |
sample-02.txt |
RE |
95 ms |
256 KB |