Submission #79389

# Submission time Handle Problem Language Result Execution time Memory
79389 2018-10-13T03:14:10 Z Plurm Boxes with souvenirs (IOI15_boxes) C++11
0 / 100
5 ms 504 KB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;

long long delivery(int N, int K, int L, int p[]) {
	vector<int> a,b;
	for(int i = 0; i < N; i++){
		if(p[i] < L-p[i]){
			a.push_back(p[i]);
		}else{
			b.push_back(L-p[i]);
		}
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	vector<long long> dpa,dpb;
	vector<long long> ansa;
	dpa.resize(a.size());
	dpa[0] = 2ll*a[0];
	long long mn = (long long)(N+K-1)/(long long)K*(long long)L;
	ansa.push_back(mn);
	for(int i = 1; i < a.size(); i++){
		dpa[i] = i >= K ? dpa[i-K] : 0ll;
		dpa[i] += 2ll*(long long)a[i];
	}
	dpb.resize(b.size());
	dpb[0] = 2ll*b[0];
	for(int i = 1; i < b.size(); i++){
		for(int j = 0; j < a.size(); j++){
			mn = min(mn,dpa[j] + dpb[i-1] + (long long)(N-i-j+K-2)/(long long)K*(long long)L);
		}
		dpb[i] = i >= K ? dpb[i-K] : 0ll;
		dpb[i] += 2ll*(long long)b[i];
	}
	for(int j = 0; j < a.size(); j++){
		mn = min(mn,dpa[j] + dpb[b.size()-1] + (long long)(N-b.size()-j+K-2)/(long long)K*(long long)L);
	}
	return mn;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i < a.size(); i++){
                 ~~^~~~~~~~~~
boxes.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i < b.size(); i++){
                 ~~^~~~~~~~~~
boxes.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < a.size(); j++){
                  ~~^~~~~~~~~~
boxes.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j = 0; j < a.size(); j++){
                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -