Submission #4028607
Source Code Expand
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const ll LINF = 1e18;
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
int to, cost;
};
//-------------------------↓↓↓↓↓↓------------------------
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> x;
rep(i, n) cin >> a[i];
rep(i, n - 1)
{
sum = a[i] + a[i + 1];
if (sum <= x)
continue;
ll her;
her = sum - x;
ans += her;
a[i + 1] -= her;
if (a[i + 1] < 0)
{
ll maina;
maina = a[i + 1];
a[i + 1] = 0;
a[i] += maina;
}
}
Cout(ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Boxes and Candies |
User |
asdf1 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1337 Byte |
Status |
AC |
Exec Time |
12 ms |
Memory |
1024 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt |
Case Name |
Status |
Exec Time |
Memory |
0_00.txt |
AC |
1 ms |
256 KB |
0_01.txt |
AC |
1 ms |
256 KB |
0_02.txt |
AC |
1 ms |
256 KB |
0_03.txt |
AC |
1 ms |
256 KB |
1_00.txt |
AC |
1 ms |
256 KB |
1_01.txt |
AC |
1 ms |
256 KB |
1_02.txt |
AC |
1 ms |
256 KB |
1_03.txt |
AC |
1 ms |
256 KB |
1_04.txt |
AC |
7 ms |
1024 KB |
1_05.txt |
AC |
7 ms |
1024 KB |
1_06.txt |
AC |
12 ms |
1024 KB |
1_07.txt |
AC |
12 ms |
1024 KB |
1_08.txt |
AC |
11 ms |
1024 KB |
1_09.txt |
AC |
11 ms |
1024 KB |
1_10.txt |
AC |
11 ms |
1024 KB |
1_11.txt |
AC |
11 ms |
1024 KB |
1_12.txt |
AC |
11 ms |
1024 KB |
1_13.txt |
AC |
11 ms |
1024 KB |
1_14.txt |
AC |
11 ms |
1024 KB |
1_15.txt |
AC |
11 ms |
1024 KB |