Submission #79850

# Submission time Handle Problem Language Result Execution time Memory
79850 2018-10-16T21:00:20 Z pzdba Hokej (COCI17_hokej) C++14
72 / 120
200 ms 10768 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) ans2.emplace_back(piipi(pii(tot, pv), idx));
		tot += l[idx];
		if(tot > m){
			tot = tot-m;
			ans += (LL)(l[idx]-tot)*k[idx];
			cur++;
			if(cur > 6) break;
			ans += (LL)tot*k[idx];
			ans1.emplace_back(idx);
		}
		else ans += (LL)l[idx]*k[idx];
		pv = idx;
		if(tot == m){
			cur++;
			if(cur > 6) break;
			pv = -1;
			tot = 0;
		}
	}

	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:45: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:48: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:49: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]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 5 ms 636 KB Output is correct
3 Correct 12 ms 960 KB Output is correct
4 Correct 2 ms 960 KB Output is correct
5 Correct 5 ms 960 KB Output is correct
6 Correct 3 ms 960 KB Output is correct
7 Incorrect 7 ms 960 KB Output isn't correct
8 Incorrect 37 ms 2700 KB Output isn't correct
9 Incorrect 200 ms 10540 KB Output isn't correct
10 Incorrect 190 ms 10768 KB Output isn't correct