Submission #79849

# Submission time Handle Problem Language Result Execution time Memory
79849 2018-10-16T20:49:17 Z pzdba Hokej (COCI17_hokej) C++14
72 / 120
189 ms 21504 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];
int cur[7];
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(tot != m) 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:46: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:49: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:50: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:13: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:15: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 4 ms 512 KB Output is correct
3 Correct 11 ms 1380 KB Output is correct
4 Correct 2 ms 1380 KB Output is correct
5 Correct 6 ms 1380 KB Output is correct
6 Correct 3 ms 1380 KB Output is correct
7 Incorrect 8 ms 1380 KB Output isn't correct
8 Incorrect 49 ms 4132 KB Output isn't correct
9 Incorrect 189 ms 16652 KB Output isn't correct
10 Incorrect 187 ms 21504 KB Output isn't correct