Submission #696475

# Submission time Handle Problem Language Result Execution time Memory
696475 2023-02-06T15:21:17 Z josiftepe Martian DNA (BOI18_dna) C++14
0 / 100
3 ms 340 KB
#include <iostream>
#include <vector>
#include <map>
using namespace std;



int main()
{
    int n, k;
    cin>>n >> k;
    int m;
    cin>>m;
    if(n > 100) {
        return 0;
    }
    vector<int> req(k + 1, 0);
    
    vector<int>v;
    
    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    int zbir=0;
    for(int j=0; j<m; j++){
    int a, b;
    //a brojot sto go barame // b za kolicina
    cin>>a>>b;
        req[a] = b;
    zbir+=b;
    }

    int min_length=2e9;
    int tmp=0;
    vector<int> t = req;
    
    for(int i=0; i<v.size(); i++){
        for(int j=0; j<v.size(); j++){
            tmp = 0;
            req = t;
            for(int k=i; k<=j; k++){
                        if(req[v[k]]>0){
                            req[v[k]]--;
                            
                        }
                bool ok = true;
                for(int x = 0; x < req.size(); x++) {
                    if(req[x] != 0) {
                        ok = false;
                        break;
                    }
                    
                }
                if(ok) {
                    min_length = min(min_length, j - i + 1);
                }
            }
        }
    }
    cout << min_length << endl;
    return 0;
}
/*
 5 2 2
 0 1 1 0 1
 0 1
1 1
 
 13 4 3
 1 1 3 2 0 1 2 0 0 0 0 3 1
 0 2
 2 1
 1 2
 
 5 3 1
 1 2 0 1 2
 0 2
 **/

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0; i<v.size(); i++){
      |                  ~^~~~~~~~~
dna.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j=0; j<v.size(); j++){
      |                      ~^~~~~~~~~
dna.cpp:49:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |                 for(int x = 0; x < req.size(); x++) {
      |                                ~~^~~~~~~~~~~~
dna.cpp:36:9: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
   36 |     int tmp=0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 300 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -