답안 #195662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
195662 2020-01-16T18:01:04 Z T0p_ Art Exhibition (JOI18_art) C++14
0 / 100
3 ms 380 KB
#include<bits/stdc++.h>
using namespace std;
 
long long a[20], b[20];
 
int main(){
	int n;
	long long ans = 0;
	scanf(" %d",&n);
	if(n > 16) return 0;
	for(int i=1 ; i<=n ; i++) scanf(" %lld %lld",&a[i],&b[i]);
	for(int i=0 ; i<(1<<n) ; i++){
		int temp = i, ch = 0;
		long long S = 0, AM = -1e18, Am = 1e18;
		for(int j=1 ; j<=n ; j++){
			if(temp%2){
				ch = 1;
				S += b[i];
				AM = max(AM, a[j]);
				Am = min(Am, a[j]);
			}
			temp/=2;
		}
		if(ch) ans = max(ans, S - AM + Am);
	}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %d",&n);
  ~~~~~^~~~~~~~~~
art.cpp:11:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1 ; i<=n ; i++) scanf(" %lld %lld",&a[i],&b[i]);
                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -