Submission #533087


Source Code Expand

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> A(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &A[i]);
		vector<int> B(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &B[i]);
		ll ans = -INFL;
		int day = 0;
		ll cur = 0;
		int maxi = -INF;
		int i = 0;
		while(day < N) {
			amax(maxi, B[i]);
			amax(ans, cur + (ll)maxi * (N - day));
			while(day < N && cur + A[i] < 0) {
				cur += maxi;
				++ day;
			}
			cur += A[i];
			++ day;
			++ i;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Submission Info

Submission Time
Task D - 高橋君の旅行
User anta
Language C++11 (GCC 4.9.2)
Score 0
Code Size 1745 Byte
Status WA
Exec Time 77 ms
Memory 1772 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:43:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &A[i]);
                      ^
./Main.cpp:46:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &B[i]);
                      ^

Judge Result

Set Name Small All
Score / Max Score 0 / 3 0 / 197
Status
AC × 12
WA × 1
AC × 43
WA × 6
Set Name Test Cases
Small 00_small_sample_00.txt, 00_small_sample_01.txt, 00_small_sample_02.txt, 00_small_sample_03.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 90_small_teuchi_00.txt, 90_small_teuchi_01.txt, 90_small_teuchi_02.txt
All 00_small_sample_00.txt, 00_small_sample_01.txt, 00_small_sample_02.txt, 00_small_sample_03.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 20_large_01.txt, 20_large_02.txt, 20_large_03.txt, 20_large_04.txt, 20_large_05.txt, 20_large_06.txt, 20_large_07.txt, 20_large_08.txt, 20_large_09.txt, 20_large_10.txt, 20_large_11.txt, 20_large_12.txt, 20_large_13.txt, 20_large_14.txt, 20_large_15.txt, 20_large_16.txt, 20_large_17.txt, 20_large_18.txt, 20_large_19.txt, 20_large_20.txt, 20_large_21.txt, 20_large_22.txt, 20_large_23.txt, 20_large_24.txt, 20_large_25.txt, 20_large_26.txt, 20_large_27.txt, 20_large_28.txt, 20_large_29.txt, 20_large_30.txt, 30_run_through_01.txt, 70_maximum_01.txt, 80_hand_01.txt, 80_hand_02.txt, 80_hand_03.txt, 80_hand_04.txt, 90_small_teuchi_00.txt, 90_small_teuchi_01.txt, 90_small_teuchi_02.txt
Case Name Status Exec Time Memory
00_small_sample_00.txt AC 69 ms 976 KB
00_small_sample_01.txt AC 62 ms 984 KB
00_small_sample_02.txt AC 31 ms 980 KB
00_small_sample_03.txt AC 28 ms 1016 KB
10_small_01.txt AC 28 ms 920 KB
10_small_02.txt AC 27 ms 920 KB
10_small_03.txt AC 27 ms 924 KB
10_small_04.txt AC 28 ms 1036 KB
10_small_05.txt AC 29 ms 932 KB
10_small_06.txt AC 29 ms 924 KB
20_large_01.txt AC 68 ms 1752 KB
20_large_02.txt AC 72 ms 1680 KB
20_large_03.txt AC 74 ms 1708 KB
20_large_04.txt AC 69 ms 1684 KB
20_large_05.txt AC 77 ms 1772 KB
20_large_06.txt AC 76 ms 1712 KB
20_large_07.txt AC 69 ms 1712 KB
20_large_08.txt AC 70 ms 1744 KB
20_large_09.txt AC 70 ms 1712 KB
20_large_10.txt AC 67 ms 1648 KB
20_large_11.txt AC 70 ms 1720 KB
20_large_12.txt AC 70 ms 1716 KB
20_large_13.txt AC 62 ms 1636 KB
20_large_14.txt AC 67 ms 1712 KB
20_large_15.txt AC 66 ms 1716 KB
20_large_16.txt AC 63 ms 1716 KB
20_large_17.txt AC 68 ms 1720 KB
20_large_18.txt AC 67 ms 1716 KB
20_large_19.txt WA 66 ms 1720 KB
20_large_20.txt AC 72 ms 1716 KB
20_large_21.txt AC 73 ms 1752 KB
20_large_22.txt AC 63 ms 1716 KB
20_large_23.txt AC 66 ms 1720 KB
20_large_24.txt AC 67 ms 1716 KB
20_large_25.txt WA 67 ms 1720 KB
20_large_26.txt AC 70 ms 1716 KB
20_large_27.txt AC 74 ms 1736 KB
20_large_28.txt WA 67 ms 1644 KB
20_large_29.txt AC 70 ms 1716 KB
20_large_30.txt AC 73 ms 1644 KB
30_run_through_01.txt WA 73 ms 1716 KB
70_maximum_01.txt AC 75 ms 1712 KB
80_hand_01.txt AC 55 ms 1716 KB
80_hand_02.txt AC 58 ms 1744 KB
80_hand_03.txt AC 65 ms 1704 KB
80_hand_04.txt WA 57 ms 1720 KB
90_small_teuchi_00.txt AC 30 ms 856 KB
90_small_teuchi_01.txt AC 38 ms 932 KB
90_small_teuchi_02.txt WA 32 ms 956 KB