Submission #282152

# Submission time Handle Problem Language Result Execution time Memory
282152 2020-08-24T04:55:17 Z arnold518 Shopping Plans (CCO20_day2problem3) C++14
5 / 25
4000 ms 303796 KB
#include <bits/stdc++.h>
using namespace std;

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

const int MAXN = 2e5;

int N, M, K;
int L[MAXN+10], R[MAXN+10];
vector<ll> A[MAXN+10];

int main()
{
	scanf("%d%d%d", &N, &M, &K);
	for(int i=1; i<=N; i++)
	{
		int t, c;
		scanf("%d%d", &t, &c);
		A[t].push_back(c);
	}
	for(int i=1; i<=M; i++) scanf("%d%d", &L[i], &R[i]);
	for(int i=1; i<=M; i++) sort(A[i].begin(), A[i].end());

	vector<ll> V; V.push_back(0);
	for(int i=1; i<=M; i++)
	{
		if(A[i].size()<V.size()) swap(A[i], V);
		priority_queue<ll> PQ;
		for(int j=0; j<V.size(); j++)
		{
			for(int k=0; k<A[i].size(); k++)
			{
				if((j+1)*(k+1)>K) break;
				PQ.push(V[j]+A[i][k]);
				if(PQ.size()>K) PQ.pop();
			}
		}
		V.clear();
		while(!PQ.empty())
		{
			V.push_back(PQ.top());
			PQ.pop();
		}
		reverse(V.begin(), V.end());
	}
	for(int i=0; i<V.size(); i++) printf("%lld\n", V[i]);
	for(int i=V.size(); i<K; i++) printf("-1\n");
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int j=0; j<V.size(); j++)
      |                ~^~~~~~~~~
Main.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    for(int k=0; k<A[i].size(); k++)
      |                 ~^~~~~~~~~~~~
Main.cpp:37:17: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     if(PQ.size()>K) PQ.pop();
      |        ~~~~~~~~~^~
Main.cpp:48:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |  for(int i=0; i<V.size(); i++) printf("%lld\n", V[i]);
      |               ~^~~~~~~~~
Main.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%d%d%d", &N, &M, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |   scanf("%d%d", &t, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:23:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |  for(int i=1; i<=M; i++) scanf("%d%d", &L[i], &R[i]);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 975 ms 85880 KB Output is correct
2 Correct 711 ms 56572 KB Output is correct
3 Correct 847 ms 69368 KB Output is correct
4 Correct 362 ms 33708 KB Output is correct
5 Correct 1071 ms 89624 KB Output is correct
6 Correct 817 ms 61304 KB Output is correct
7 Correct 214 ms 17020 KB Output is correct
8 Correct 17 ms 5504 KB Output is correct
9 Correct 6 ms 5248 KB Output is correct
10 Correct 668 ms 55608 KB Output is correct
11 Correct 12 ms 5504 KB Output is correct
12 Correct 7 ms 5376 KB Output is correct
13 Correct 42 ms 7800 KB Output is correct
14 Correct 832 ms 67372 KB Output is correct
15 Correct 6 ms 5248 KB Output is correct
16 Correct 28 ms 6776 KB Output is correct
17 Correct 368 ms 34552 KB Output is correct
18 Correct 10 ms 5632 KB Output is correct
19 Correct 50 ms 8696 KB Output is correct
20 Correct 1025 ms 90104 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 10 ms 5376 KB Output is correct
23 Correct 17 ms 5504 KB Output is correct
24 Correct 13 ms 5376 KB Output is correct
25 Correct 13 ms 5376 KB Output is correct
26 Correct 761 ms 68984 KB Output is correct
27 Correct 341 ms 34296 KB Output is correct
28 Correct 16 ms 5504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4065 ms 303796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 975 ms 85880 KB Output is correct
2 Correct 711 ms 56572 KB Output is correct
3 Correct 847 ms 69368 KB Output is correct
4 Correct 362 ms 33708 KB Output is correct
5 Correct 1071 ms 89624 KB Output is correct
6 Correct 817 ms 61304 KB Output is correct
7 Correct 214 ms 17020 KB Output is correct
8 Correct 17 ms 5504 KB Output is correct
9 Correct 6 ms 5248 KB Output is correct
10 Correct 668 ms 55608 KB Output is correct
11 Correct 12 ms 5504 KB Output is correct
12 Correct 7 ms 5376 KB Output is correct
13 Correct 42 ms 7800 KB Output is correct
14 Correct 832 ms 67372 KB Output is correct
15 Correct 6 ms 5248 KB Output is correct
16 Correct 28 ms 6776 KB Output is correct
17 Correct 368 ms 34552 KB Output is correct
18 Correct 10 ms 5632 KB Output is correct
19 Correct 50 ms 8696 KB Output is correct
20 Correct 1025 ms 90104 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 10 ms 5376 KB Output is correct
23 Correct 17 ms 5504 KB Output is correct
24 Correct 13 ms 5376 KB Output is correct
25 Correct 13 ms 5376 KB Output is correct
26 Correct 761 ms 68984 KB Output is correct
27 Correct 341 ms 34296 KB Output is correct
28 Correct 16 ms 5504 KB Output is correct
29 Execution timed out 4065 ms 303796 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 5632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 975 ms 85880 KB Output is correct
2 Correct 711 ms 56572 KB Output is correct
3 Correct 847 ms 69368 KB Output is correct
4 Correct 362 ms 33708 KB Output is correct
5 Correct 1071 ms 89624 KB Output is correct
6 Correct 817 ms 61304 KB Output is correct
7 Correct 214 ms 17020 KB Output is correct
8 Correct 17 ms 5504 KB Output is correct
9 Correct 6 ms 5248 KB Output is correct
10 Correct 668 ms 55608 KB Output is correct
11 Correct 12 ms 5504 KB Output is correct
12 Correct 7 ms 5376 KB Output is correct
13 Correct 42 ms 7800 KB Output is correct
14 Correct 832 ms 67372 KB Output is correct
15 Correct 6 ms 5248 KB Output is correct
16 Correct 28 ms 6776 KB Output is correct
17 Correct 368 ms 34552 KB Output is correct
18 Correct 10 ms 5632 KB Output is correct
19 Correct 50 ms 8696 KB Output is correct
20 Correct 1025 ms 90104 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 10 ms 5376 KB Output is correct
23 Correct 17 ms 5504 KB Output is correct
24 Correct 13 ms 5376 KB Output is correct
25 Correct 13 ms 5376 KB Output is correct
26 Correct 761 ms 68984 KB Output is correct
27 Correct 341 ms 34296 KB Output is correct
28 Correct 16 ms 5504 KB Output is correct
29 Execution timed out 4065 ms 303796 KB Time limit exceeded
30 Halted 0 ms 0 KB -