답안 #79852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
79852 2018-10-16T21:07:24 Z pzdba Hokej (COCI17_hokej) C++14
0 / 120
190 ms 10872 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<pii, int> piipi;
int k[500005], l[500005];
piipi p[500005];
vector<int> ans1;
vector<piipi> ans2;
int main(){
	int m, n;
	scanf("%d%d", &m, &n);
	for(int i=1;i<=n;i++){
		scanf("%d%d", &k[i], &l[i]);
		p[i] = piipi(pii(-k[i], l[i]), i);
	}
	sort(p+1, p+1+n);

	LL ans = 0;
	int cur = 1, tot = 0, pv = -1;
	for(int i=1;i<=n;i++){
		int idx = p[i].second;
		if(tot == 0) ans1.emplace_back(idx);
		else if(pv != -1 && tot != m) ans2.emplace_back(piipi(pii(tot, pv), idx));
		if(tot+l[idx] <= m){
			tot += l[idx];
			ans += (LL)l[idx]*k[idx];
			if(tot == m){
				cur++;
				tot = 0;
				if(cur > 6) break;
			}
		}
		else{
			tot += l[idx];
			ans += (LL)(tot-m)*k[idx];
			l[idx] -= tot-m;
			i--;
			cur++;
			tot = 0;
			if(cur > 6) break;
		}
		pv = idx;
	}

	printf("%lld\n", ans);
	for(int i=0;i<ans1.size();i++) printf("%d ", ans1[i]);
	printf("\n");
	sort(ans2.begin(), ans2.end());
	printf("%d\n", ans2.size());
	for(int i=0;i<ans2.size();i++) printf("%d %d %d\n", ans2[i].first.first, ans2[i].first.second, ans2[i].second);
}

Compilation message

hokej.cpp: In function 'int main()':
hokej.cpp:47:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<ans1.size();i++) printf("%d ", ans1[i]);
              ~^~~~~~~~~~~~
hokej.cpp:50:28: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::pair<std::pair<int, int>, int> >::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", ans2.size());
                 ~~~~~~~~~~~^
hokej.cpp:51:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<ans2.size();i++) printf("%d %d %d\n", ans2[i].first.first, ans2[i].first.second, ans2[i].second);
              ~^~~~~~~~~~~~
hokej.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &m, &n);
  ~~~~~^~~~~~~~~~~~~~~~
hokej.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &k[i], &l[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Failed 2 ms 376 KB some player fainted
2 Failed 4 ms 580 KB some player fainted
3 Failed 12 ms 928 KB some player fainted
4 Failed 2 ms 928 KB some player fainted
5 Failed 8 ms 928 KB some player fainted
6 Failed 4 ms 928 KB some player fainted
7 Incorrect 5 ms 928 KB Output isn't correct
8 Incorrect 37 ms 2776 KB Output isn't correct
9 Incorrect 189 ms 10448 KB Output isn't correct
10 Failed 190 ms 10872 KB the answer doesn't match with the value Z