Submission #1040483

# Submission time Handle Problem Language Result Execution time Memory
1040483 2024-08-01T05:54:56 Z 김은성(#10995) How to Avoid Disqualification in 75 Easy Steps (CEOI23_avoid) C++17
Compilation error
0 ms 0 KB
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const ll INF = 0x3fffffffffffffff;
ll c[250009], s[250009];
bool ch[250009];
ll profit(int l, int r, int k){
	vector<ll> temp;
	if(r-l+1 < k)
		return -INF;
	int i;
	ll ans = 0;
	vector<ll> p;
	for(i=l; i<=r; i++){
		ans -= c[i];
		p.push_back(s[i]);
	}
	sort(p.begin(), p.end(), [](ll &u, ll &v){return u>v;});
	for(i=0; i<k; i++)
		ans += p[i];
	return ans;
}

ll profit_ch(int l, int r, int k){
	vector<ll> temp;
	if(r-l+1 < k)
		return -INF;
	int i;
	ll ans = 0;
	vector<pair<ll, int> > p;
	for(i=l; i<=r; i++){
		ans -= c[i];
		p.push_back(make_pair(-s[i], i));
	}
	sort(p.begin(), p.end());
	for(i=0; i<p.size(); i++){
		if(-p[i].first >= -p[k-1].first)
			ch[p[i].second] = 1;
	}
	return ans;
}
int main(){
	int n, m, i, j;
	ll ans = -INF;
	scanf("%d %d", &n, &m);
	for(i=1; i<=n; i++)
		scanf("%lld", &c[i]);
	for(i=1; i<=n; i++)
		scanf("%lld", &s[i]);
	for(i=1; i<=n; i++){
		for(j=i; j<=n; j++)
			ans = max(ans, profit(i, j, m));
	}
	for(i=1; i<=n; i++){
		for(j=i; j<=n; j++){
			if(profit(i, j, m) == ans)
				profit_ch(i, j, m);
		}
	}
	printf("%lld\n", ans);
	for(i=1; i<=n; i++){
		printf("%d", ch[i]);
	}
	return 0;
}

Compilation message

avoid.cpp: In function 'll profit_ch(int, int, int)':
avoid.cpp:44:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(i=0; i<p.size(); i++){
      |           ~^~~~~~~~~
avoid.cpp: In function 'int main()':
avoid.cpp:53:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
avoid.cpp:55:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |   scanf("%lld", &c[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
avoid.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   scanf("%lld", &s[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccyUU1IL.o: in function `main':
interface.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc6TIRgL.o:avoid.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccyUU1IL.o: in function `main':
interface.cpp:(.text.startup+0x1b): undefined reference to `scout(int, int)'
collect2: error: ld returned 1 exit status