Submission #1099780

# Submission time Handle Problem Language Result Execution time Memory
1099780 2024-10-12T05:15:54 Z model_code Nile (IOI24_nile) C++17
17 / 100
2000 ms 4812 KB
// time_limit/bakry_n2.cpp

#include <bits/stdc++.h>

using namespace std ;

vector<long long>calculate_costs(vector<int>W, vector<int>A, vector<int>B, vector<int>E) {
	vector< array<int , 3> >ord;
	int n = W.size(), q = E.size();
	for(int i = 0; i < n; ++i)
		ord.push_back({W[i], A[i], B[i]});
	sort(ord.begin(), ord.end());
	for(int i = 0; i < n; ++i)
		W[i] = ord[i][0], A[i] = ord[i][1], B[i] = ord[i][2];
	vector<long long>v;
	for(int curq = 0; curq < E.size(); ++curq)
	{
		int d = E[curq];
		vector<long long>dp(n);
		dp[0] = A[0];
		for(int i = 1; i < n; ++i)
		{
			dp[i] = dp[i-1] + A[i]; 
			long long sum = 0 ;
			for(int j = i-1; j >= 0; --j)
			{
				if(W[i] - W[j] <= d)
				{
					long long x = 0;
					if(j > 0)
						x = dp[j-1];
					dp[i] = min(dp[i], x + B[i] + B[j] + sum);
				}
				sum += A[j];
			}
		}
		v.push_back(dp[n-1]);
	}
	return v;
}

Compilation message

nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:16:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int curq = 0; curq < E.size(); ++curq)
      |                    ~~~~~^~~~~~~~~~
nile.cpp:9:20: warning: unused variable 'q' [-Wunused-variable]
    9 |  int n = W.size(), q = E.size();
      |                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 344 KB Output is correct
2 Correct 18 ms 344 KB Output is correct
3 Correct 17 ms 348 KB Output is correct
4 Correct 17 ms 524 KB Output is correct
5 Correct 20 ms 344 KB Output is correct
6 Correct 19 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2016 ms 4804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2059 ms 4812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 344 KB Output is correct
2 Correct 18 ms 344 KB Output is correct
3 Correct 17 ms 348 KB Output is correct
4 Correct 17 ms 524 KB Output is correct
5 Correct 20 ms 344 KB Output is correct
6 Correct 19 ms 348 KB Output is correct
7 Correct 12 ms 516 KB Output is correct
8 Correct 12 ms 520 KB Output is correct
9 Correct 12 ms 348 KB Output is correct
10 Correct 12 ms 524 KB Output is correct
11 Correct 15 ms 528 KB Output is correct
12 Correct 12 ms 520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 344 KB Output is correct
2 Correct 18 ms 344 KB Output is correct
3 Correct 17 ms 348 KB Output is correct
4 Correct 17 ms 524 KB Output is correct
5 Correct 20 ms 344 KB Output is correct
6 Correct 19 ms 348 KB Output is correct
7 Execution timed out 2016 ms 4804 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2059 ms 4812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 17 ms 344 KB Output is correct
3 Correct 18 ms 344 KB Output is correct
4 Correct 17 ms 348 KB Output is correct
5 Correct 17 ms 524 KB Output is correct
6 Correct 20 ms 344 KB Output is correct
7 Correct 19 ms 348 KB Output is correct
8 Execution timed out 2016 ms 4804 KB Time limit exceeded
9 Halted 0 ms 0 KB -