답안 #32660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
32660 2017-10-13T17:20:46 Z imaxblue Ice Hockey World Championship (CEOI15_bobek) C++14
20 / 100
1000 ms 136488 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()


int n, p, t, bit[1 << 22];
ll k, a[45], ans;
map<ll,int> m;
vector<pair<ll, int> > v;
void add(int P){
	for(; P<(1 << 21); P+=P&-P) bit[P]++;
}
int sum(int P){
	int C=0; for(;P>0;P-=P&-P) C+=bit[P]; return C;
}
void dfs(int N, ll S){
	if (S>k) return;
	if (N==20 || N==n){
		if (t==1) k-S;
		v.pb(mp(S, t));
		m[S]=0;
		return;
	}
	dfs(N+1, S);
	dfs(N+1, S+a[N]);
}
int main() {
	cin >> n >> k;
	fox(l,n) cin >> a[l];
	if (n<=20){
		t++;
	} else {
		dfs(0, 0);
		t++;
		n-=20;
		fox(l, 20) a[l]=a[l+20];
	}
	dfs(0,0);
	//return 0;
	sort(v.begin(), v.end());
	fox(l, v.size()) m[v[l].x]=0;
	for (auto i:m) m[i.x]=++p;
	add(1);
	fox(l, v.size()){
		//cout << v[l].x << endl;
		if (v[l].y==0) add(m[v[l].x]);
	}
	fox(l, v.size()){
		if (v[l].y) ans+=sum(m[v[l].x]);
	}
	cout << ans;
	return 0;
}

Compilation message

bobek.cpp: In function 'void dfs(int, long long int)':
bobek.cpp:41:14: warning: statement has no effect [-Wunused-value]
   if (t==1) k-S;
              ^
bobek.cpp: In function 'int main()':
bobek.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
                                  ^
bobek.cpp:63:2: note: in expansion of macro 'fox'
  fox(l, v.size()) m[v[l].x]=0;
  ^
bobek.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
                                  ^
bobek.cpp:66:2: note: in expansion of macro 'fox'
  fox(l, v.size()){
  ^
bobek.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
                                  ^
bobek.cpp:70:2: note: in expansion of macro 'fox'
  fox(l, v.size()){
  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 18408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 18408 KB Output is correct
2 Correct 0 ms 18408 KB Output is correct
3 Correct 0 ms 18408 KB Output is correct
4 Correct 0 ms 18408 KB Output is correct
5 Correct 0 ms 18408 KB Output is correct
6 Correct 0 ms 18540 KB Output is correct
7 Correct 0 ms 18408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 25616 KB Output is correct
2 Correct 33 ms 20808 KB Output is correct
3 Correct 79 ms 23432 KB Output is correct
4 Correct 0 ms 18408 KB Output is correct
5 Correct 6 ms 20036 KB Output is correct
6 Execution timed out 1000 ms 100304 KB Execution timed out
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 83012 KB Execution timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 463 ms 68652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 513 ms 69312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 87536 KB Execution timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 136488 KB Execution timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 133076 KB Execution timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 134244 KB Execution timed out
2 Halted 0 ms 0 KB -