Submission #282155

# Submission time Handle Problem Language Result Execution time Memory
282155 2020-08-24T04:59:33 Z arnold518 Shopping Plans (CCO20_day2problem3) C++14
5 / 25
4000 ms 10840 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 1081 ms 5368 KB Output is correct
2 Correct 823 ms 5308 KB Output is correct
3 Correct 963 ms 5368 KB Output is correct
4 Correct 418 ms 5288 KB Output is correct
5 Correct 1079 ms 5368 KB Output is correct
6 Correct 936 ms 5248 KB Output is correct
7 Correct 305 ms 5248 KB Output is correct
8 Correct 21 ms 5248 KB Output is correct
9 Correct 6 ms 5276 KB Output is correct
10 Correct 815 ms 5320 KB Output is correct
11 Correct 11 ms 5248 KB Output is correct
12 Correct 6 ms 5120 KB Output is correct
13 Correct 45 ms 5120 KB Output is correct
14 Correct 942 ms 5312 KB Output is correct
15 Correct 5 ms 5120 KB Output is correct
16 Correct 29 ms 5120 KB Output is correct
17 Correct 421 ms 5292 KB Output is correct
18 Correct 10 ms 5120 KB Output is correct
19 Correct 50 ms 5120 KB Output is correct
20 Correct 1110 ms 5368 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 10 ms 5120 KB Output is correct
23 Correct 20 ms 5248 KB Output is correct
24 Correct 19 ms 5248 KB Output is correct
25 Correct 17 ms 5248 KB Output is correct
26 Correct 913 ms 5368 KB Output is correct
27 Correct 401 ms 5248 KB Output is correct
28 Correct 20 ms 5248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4046 ms 10840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1081 ms 5368 KB Output is correct
2 Correct 823 ms 5308 KB Output is correct
3 Correct 963 ms 5368 KB Output is correct
4 Correct 418 ms 5288 KB Output is correct
5 Correct 1079 ms 5368 KB Output is correct
6 Correct 936 ms 5248 KB Output is correct
7 Correct 305 ms 5248 KB Output is correct
8 Correct 21 ms 5248 KB Output is correct
9 Correct 6 ms 5276 KB Output is correct
10 Correct 815 ms 5320 KB Output is correct
11 Correct 11 ms 5248 KB Output is correct
12 Correct 6 ms 5120 KB Output is correct
13 Correct 45 ms 5120 KB Output is correct
14 Correct 942 ms 5312 KB Output is correct
15 Correct 5 ms 5120 KB Output is correct
16 Correct 29 ms 5120 KB Output is correct
17 Correct 421 ms 5292 KB Output is correct
18 Correct 10 ms 5120 KB Output is correct
19 Correct 50 ms 5120 KB Output is correct
20 Correct 1110 ms 5368 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 10 ms 5120 KB Output is correct
23 Correct 20 ms 5248 KB Output is correct
24 Correct 19 ms 5248 KB Output is correct
25 Correct 17 ms 5248 KB Output is correct
26 Correct 913 ms 5368 KB Output is correct
27 Correct 401 ms 5248 KB Output is correct
28 Correct 20 ms 5248 KB Output is correct
29 Execution timed out 4046 ms 10840 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 1081 ms 5368 KB Output is correct
2 Correct 823 ms 5308 KB Output is correct
3 Correct 963 ms 5368 KB Output is correct
4 Correct 418 ms 5288 KB Output is correct
5 Correct 1079 ms 5368 KB Output is correct
6 Correct 936 ms 5248 KB Output is correct
7 Correct 305 ms 5248 KB Output is correct
8 Correct 21 ms 5248 KB Output is correct
9 Correct 6 ms 5276 KB Output is correct
10 Correct 815 ms 5320 KB Output is correct
11 Correct 11 ms 5248 KB Output is correct
12 Correct 6 ms 5120 KB Output is correct
13 Correct 45 ms 5120 KB Output is correct
14 Correct 942 ms 5312 KB Output is correct
15 Correct 5 ms 5120 KB Output is correct
16 Correct 29 ms 5120 KB Output is correct
17 Correct 421 ms 5292 KB Output is correct
18 Correct 10 ms 5120 KB Output is correct
19 Correct 50 ms 5120 KB Output is correct
20 Correct 1110 ms 5368 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 10 ms 5120 KB Output is correct
23 Correct 20 ms 5248 KB Output is correct
24 Correct 19 ms 5248 KB Output is correct
25 Correct 17 ms 5248 KB Output is correct
26 Correct 913 ms 5368 KB Output is correct
27 Correct 401 ms 5248 KB Output is correct
28 Correct 20 ms 5248 KB Output is correct
29 Execution timed out 4046 ms 10840 KB Time limit exceeded
30 Halted 0 ms 0 KB -