제출 #282152

#제출 시각아이디문제언어결과실행 시간메모리
282152arnold518Shopping Plans (CCO20_day2problem3)C++14
5 / 25
4065 ms303796 KiB
#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");
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...