Submission #961723

# Submission time Handle Problem Language Result Execution time Memory
961723 2024-04-12T11:13:10 Z Ahmed57 Aliens (IOI16_aliens) C++17
0 / 100
1 ms 376 KB
#include <bits/stdc++.h>
#include "aliens.h"

using namespace std;
long long take_photos(int n, int m, int k, vector<int> r,vector<int> c){
    vector<pair<long long,long long>> seg1,seg;
    for(int i = 0;i<n;i++){
        seg1.push_back({min(c[i],r[i]),max(c[i],r[i])});
    }
    long long ma = -1e18;
    for(int i = 0;i<n;i++){
        if(seg1[i].second>ma){
            seg.push_back(seg1[i]);
            ma = seg1[i].second;
        }
    }
    long long dp[seg.size()+1][k+1];
    for(int i = 0;i<=k;i++)dp[0][i] = 0;
    for(int i = 1;i<=seg.size();i++){
        dp[i][0] = 1e18;
        for(int j = 1;j<=k;j++){
            dp[i][j] = 1e18;
            for(int e = 0;e<i;e++){
                dp[i][j] = min(dp[i][j],dp[e][j-1]+(seg[i-1].second-seg[e].first+1)*(seg[i-1].second-seg[e].first+1)-(e==0?0:max(0ll,seg[e-1].second-seg[e].first+1)*max(0ll,seg[e-1].second-seg[e].first+1)));
            }
        }
    }
    return dp[seg.size()][k];
}

Compilation message

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 1;i<=seg.size();i++){
      |                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct answer: answer = 4
2 Correct 0 ms 344 KB Correct answer: answer = 4
3 Correct 0 ms 348 KB Correct answer: answer = 4
4 Incorrect 0 ms 348 KB Wrong answer: output = 9, expected = 12
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct answer: answer = 1
2 Correct 1 ms 376 KB Correct answer: answer = 4
3 Correct 0 ms 348 KB Correct answer: answer = 1
4 Correct 0 ms 348 KB Correct answer: answer = 5
5 Incorrect 0 ms 348 KB Wrong answer: output = 3, expected = 41
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct answer: answer = 4
2 Correct 0 ms 344 KB Correct answer: answer = 4
3 Correct 0 ms 348 KB Correct answer: answer = 4
4 Incorrect 0 ms 348 KB Wrong answer: output = 9, expected = 12
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct answer: answer = 4
2 Correct 0 ms 344 KB Correct answer: answer = 4
3 Correct 0 ms 348 KB Correct answer: answer = 4
4 Incorrect 0 ms 348 KB Wrong answer: output = 9, expected = 12
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct answer: answer = 4
2 Correct 0 ms 344 KB Correct answer: answer = 4
3 Correct 0 ms 348 KB Correct answer: answer = 4
4 Incorrect 0 ms 348 KB Wrong answer: output = 9, expected = 12
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct answer: answer = 4
2 Correct 0 ms 344 KB Correct answer: answer = 4
3 Correct 0 ms 348 KB Correct answer: answer = 4
4 Incorrect 0 ms 348 KB Wrong answer: output = 9, expected = 12
5 Halted 0 ms 0 KB -