답안 #20348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20348 2017-02-07T07:22:52 Z Can polan into space? (OJUZ11_space) C++
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pii;

int n;
lint a[1000005], b[1000005], c[1000005], dp[1000005], trk[1000005];

void update(lint &a, lint b, lint &c, lint d){
	if(a < b){
		a = b;
		c = d;
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
		a[i] += a[i-1];
		b[i] += b[i-1];
		c[i] += c[i-1];
	}
	if(n > 10000){
		puts("-1");
		return 0;
	}
	dp[1] = a[1];
	for(int i=2; i<=n; i++){
		dp[i] = -1e18;
		update(dp[i], dp[i-1] + b[i] - b[i-1], trk[i], i-1);
		update(dp[i], b[i-1] + a[i] - a[i-1], trk[i], 0);
		for(int j=1; j<i-1; j++){
			update(dp[i], dp[j] + c[j+1] - c[j] + a[i] - a[i-1] + b[i-1] - b[j+1], trk[i], j);
		}
	}
	printf("%lld\n", dp[n]);
	vector<int> v;
	for(int i=n; i; i = trk[i]){
		for(int j=trk[i] + 1; j<=i; j++){
			v.push_back(j);
		}
	}
	reverse(v.begin(), v.end());
	for(auto &i : v) printf("%d ", i);
}

Compilation message

space.cpp: In function 'int main()':
space.cpp:46:6: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
  for(auto &i : v) printf("%d ", i);
      ^
space.cpp:46:12: error: ISO C++ forbids declaration of 'i' with no type [-fpermissive]
  for(auto &i : v) printf("%d ", i);
            ^
space.cpp:46:16: warning: range-based 'for' loops only available with -std=c++11 or -std=gnu++11
  for(auto &i : v) printf("%d ", i);
                ^
space.cpp:18:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
space.cpp:20:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
                                            ^