Submission #496318

# Submission time Handle Problem Language Result Execution time Memory
496318 2021-12-21T05:37:24 Z AQ0212 Meteors (POI11_met) C++17
24 / 100
6000 ms 22812 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <cstring>

#define ll long long int
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using namespace std;

ll l, r, a, p[ 500111 ], o[ 500111 ], cnt[ 500111 ], ans[ 500111 ];
vector < ll > v[ 500111 ];

int main(){
    ll n, m, k;

    cin >> n >> m;

    for(int i = 1; i <= m; i ++){
        cin >> o[ i ];
        v[ o[ i ] ].pb(i);
    }
    for(int i = 1; i <= n; i ++){
        cin >> p[ i ];
    }

    cin >> k;
    ll t = 1;
    while(k --){
        cin >> l >> r >> a;

        if(l <= r){
            for(int i = 1; i <= m; i ++){
                for(int j = 0; j < v[ i ].size(); j ++){
                    if(l <= v[ i ][ j ] && v[ i ][ j ] <= r)
                        cnt[ i ] += a;
                }
                if(cnt[ i ] >= p[ i ] && !ans[ i ])
                    ans[ i ] = t;
            }
        }else{
            for(int i = 1; i <= m; i ++){
                for(int j = 0; j < v[ i ].size(); j ++){
                    if(l <= v[ i ][ j ] || v[ i ][ j ] <= r)
                        cnt[ i ] += a;
                }
                if(cnt[ i ] >= p[ i ] && !ans[ i ])
                    ans[ i ] = t;
            }
        }

        t ++;
    }

    for(int i = 1; i <= n; i ++){
        if(ans[ i ])
            cout << ans[ i ] << "\n";
        else
            cout << "NIE\n";
    }

    // for(int i = 1; i <= n; i ++){
    //     cout << i << ":" << cnt[ i ] << "\n";
    // }
}


Compilation message

met.cpp: In function 'int main()':
met.cpp:43:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |                 for(int j = 0; j < v[ i ].size(); j ++){
      |                                ~~^~~~~~~~~~~~~~~
met.cpp:52:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                 for(int j = 0; j < v[ i ].size(); j ++){
      |                                ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 11980 KB Output is correct
2 Correct 13 ms 12020 KB Output is correct
3 Correct 14 ms 12048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 12104 KB Output is correct
2 Correct 16 ms 12108 KB Output is correct
3 Correct 12 ms 12124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5705 ms 13420 KB Output is correct
2 Execution timed out 6028 ms 14112 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6040 ms 13644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5390 ms 13816 KB Output is correct
2 Execution timed out 6021 ms 13976 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6088 ms 13256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6084 ms 22812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6097 ms 22520 KB Time limit exceeded
2 Halted 0 ms 0 KB -