답안 #29302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29302 2017-07-19T01:52:42 Z 시제연(#1167) Meteors (POI11_met) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#define s first
#define e second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

int n, m, k;

struct query {
	int l, r; ll a;
	query(){}
	query(int l, int r, ll a):l(l),r(r),a(a){}
};

struct idxtree {
	ll tree[1050000];
	int key = 524288;
	void init() {
		for (int i=0;i<key*2;i++) tree[i] = 0;
	}
	void updr(int s, int e, ll val) {
		s+=key;e+=key;
		while(s<=e) {
			if (s&1) tree[s] += val;
			if (~e&1) tree[e] += val;
			s = (s+1)>>1; e = (e-1)>>1;
		}
	}
	ll getv(int idx) {
		ll res = 0;
		idx += key;
		while(idx>0) {
			res += tree[idx];
			idx>>=1;
		}
		return res;
	}
	void upd(int s, int e, ll val) {
		if (s<=e) updr(s,e,val);
		else {
			updr(s,m-1,val);
			updr(0,e,val);
		}
	}
} it;

int own[300100];
vector<int> lis[300100];
ll p[300100];
query arr[300100];
vector<int> loc[300100];
vector<int> tmp[300100];
pii yan[300100];
int res[300100];

void init(int s, int e) {
	if (s>e) return;
	int m = (s+e)>>1;
	yan[m] = pii(s,e);
	init(s,m-1); init(m+1,e);
}

void pb() {
	int i;
	for (i=0;i<n;i++) tmp[(k+1)/2].push_back(i);
	init(1,k);
	while(true) {
		for (i=1;i<=k;i++) {
			loc[i].assign(tmp[i].begin(),tmp[i].end());
			tmp[i].clear();
		}
		bool flag = 1;
		it.init();
		for (i=1;i<=k;i++) {
			it.upd(arr[i-1].l,arr[i-1].r,arr[i-1].a);
			for (int v : loc[i]) {
				flag = 0;
				ll sum = 0;
				for (int l : lis[v]) {
					sum += it.getv(l);
					sum = min(sum,1e9+10);
				}
				if (sum>=p[v]) {
					if (i==yan[i].s) res[v] = i;
					else tmp[(yan[i].s+i-1)/2].push_back(v);
				}
				else {
					if (i==yan[i].e) res[v] = i+1;
					else tmp[(yan[i].e+i+1)/2].push_back(v);
				}
			}
		}
		if (flag) break;
	}
}

int main() {
	int i;

	scanf("%d%d",&n,&m);
	for (i=0;i<m;i++) {
		scanf("%d",&own[i]); own[i]--;
		lis[own[i]].push_back(i);
	}
	for (i=0;i<n;i++) scanf("%lld",&p[i]);
	scanf("%d",&k);
	for (i=0;i<k;i++) {
		int l, r; ll a;
		scanf("%d%d%lld",&l,&r,&a); l--; r--;
		arr[i] = query(l,r,a);
	}
	pb();
	for (i=0;i<n;i++) {
		if (res[i]>=k+1) printf("NIE\n");
		else printf("%d\n",res[i]);
	}

    return 0;
}

Compilation message

met.cpp: In function 'void pb()':
met.cpp:85:26: error: no matching function for call to 'min(ll&, double)'
      sum = min(sum,1e9+10);
                          ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from met.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
met.cpp:85:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
      sum = min(sum,1e9+10);
                          ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from met.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
met.cpp:85:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
      sum = min(sum,1e9+10);
                          ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from met.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3445:5: note: candidate: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^
/usr/include/c++/5/bits/stl_algo.h:3445:5: note:   template argument deduction/substitution failed:
met.cpp:85:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
      sum = min(sum,1e9+10);
                          ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from met.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3451:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algo.h:3451:5: note:   template argument deduction/substitution failed:
met.cpp:85:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
      sum = min(sum,1e9+10);
                          ^
met.cpp: In function 'int main()':
met.cpp:104:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
met.cpp:106:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&own[i]); own[i]--;
                      ^
met.cpp:109:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i=0;i<n;i++) scanf("%lld",&p[i]);
                                       ^
met.cpp:110:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&k);
                ^
met.cpp:113:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%lld",&l,&r,&a); l--; r--;
                             ^