Submission #496398

# Submission time Handle Problem Language Result Execution time Memory
496398 2021-12-21T07:22:58 Z Nalrimet Meteors (POI11_met) C++17
74 / 100
5817 ms 2240 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 3 * 1e5 + 5;
const long long inf = 1000000000;
#define ll long long

#define F first
#define S second
#define pb push_back

int n, m, a[N], k, l, r, ans[N];
ll b[N], x;

 main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;

    for(int i = 1; i <= m; ++i){
        cin >> a[i];
    }

    for(int i = 1; i <= n; ++i){
        cin >> b[i];
    }

    cin >> k;
     if(k > 1e5 || m > 1e5 || n > 1e5) {
        cout << "GG WP";
        return 0;
    }
    for(int i = 1; i <= k; ++i){
        cin >> l >> r >> x;
        if(l <= r){
            for(int j = l; j <= r; ++j){
                if(b[a[j]] <= 0) continue;
                else{
                    b[a[j]] -= x;
                    if(b[a[j]] <= 0) ans[a[j]] = i;
                }
            }
        }
        else{
            for(int j = l; j <= m; ++j){
                if(b[a[j]] <= 0) continue;
                else{
                    b[a[j]] -= x;
                    if(b[a[j]] <= 0) ans[a[j]] = i;
                }
            }
            for(int j = 1; j <= r; ++j){
                if(b[a[j]] <= 0) continue;
                else{
                    b[a[j]] -= x;
                    if(b[a[j]] <= 0) ans[a[j]] = i;
                }
            }

        }
//        for(int i = 1; i <= n; ++i){
//            cout << b[i] << ' ';
//        }
//        cout << '\n';
    }

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

Compilation message

met.cpp:15:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 |  main() {
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 743 ms 544 KB Output is correct
2 Correct 5817 ms 764 KB Output is correct
3 Correct 3146 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1682 ms 616 KB Output is correct
2 Correct 2312 ms 612 KB Output is correct
3 Correct 1849 ms 800 KB Output is correct
4 Correct 9 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2294 ms 676 KB Output is correct
2 Correct 4760 ms 924 KB Output is correct
3 Correct 47 ms 324 KB Output is correct
4 Correct 2159 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2614 ms 504 KB Output is correct
2 Correct 4261 ms 620 KB Output is correct
3 Correct 1430 ms 520 KB Output is correct
4 Correct 5046 ms 932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 2240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 2084 KB Output isn't correct
2 Halted 0 ms 0 KB -