답안 #50527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50527 2018-06-11T10:33:05 Z MrPlany K개의 묶음 (IZhO14_blocks) C++17
0 / 100
4 ms 588 KB
#include<bits/stdc++.h>
using namespace std;
int i,j,k,l,m,n,a[1009],dp[109][109],x,y,jem;
vector<int>mx,mn;
int main ()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>a[i];
	l=a[1]; x=1; y=1; mn.push_back(a[1]);
	for(int i=1; i<=n; i++)
	{
		if(a[i]<l) {mx.push_back(l); x++; y=1; mn.push_back(a[i]);}
		l=a[i];
		dp[x][y]=l; y++;
	}
	mx.push_back(l);
	if(mx.size()==k)
	{
		for(int i=0; i<mx.size(); i++)
		{
			for(int j=0; j<mx.size(); j++)
			{
				if(mx[i]<mx[j]) mx[i]=mn[i];
			}
		}
		for(int i=0; i<mx.size(); i++) jem+=mx[i];
	}
	else if(mx.size()>k)
	{
		for(int i=0; i<mx.size(); i++)
		{
			for(int j=0; j<mx.size(); j++)
			{
				if(mx[i]<mx[j]) mx[i]=mn[i];
			}
		}
		sort(mx.begin(),mx.end());
		jem+=mx[mx.size()-1];
		for(int i=0; i<k-1; i++) jem+=mx[i];
	}
	
	cout<<jem; 
}

Compilation message

blocks.cpp: In function 'int main()':
blocks.cpp:17:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(mx.size()==k)
     ~~~~~~~~~^~~
blocks.cpp:19:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<mx.size(); i++)
                ~^~~~~~~~~~
blocks.cpp:21:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0; j<mx.size(); j++)
                 ~^~~~~~~~~~
blocks.cpp:26:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<mx.size(); i++) jem+=mx[i];
                ~^~~~~~~~~~
blocks.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  else if(mx.size()>k)
          ~~~~~~~~~^~
blocks.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<mx.size(); i++)
                ~^~~~~~~~~~
blocks.cpp:32:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0; j<mx.size(); j++)
                 ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Incorrect 3 ms 448 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 556 KB Output is correct
3 Correct 3 ms 556 KB Output is correct
4 Incorrect 2 ms 556 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 588 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -