답안 #496253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496253 2021-12-21T04:13:08 Z Nalrimet Meteors (POI11_met) C++17
74 / 100
6000 ms 2244 KB
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#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;

    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:22:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 |  main() {
      |  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 451 ms 560 KB Output is correct
2 Correct 5632 ms 904 KB Output is correct
3 Correct 3179 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1794 ms 628 KB Output is correct
2 Correct 2384 ms 636 KB Output is correct
3 Correct 1640 ms 804 KB Output is correct
4 Correct 10 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2005 ms 564 KB Output is correct
2 Correct 4274 ms 808 KB Output is correct
3 Correct 30 ms 204 KB Output is correct
4 Correct 2208 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2417 ms 516 KB Output is correct
2 Correct 4580 ms 624 KB Output is correct
3 Correct 1481 ms 536 KB Output is correct
4 Correct 5417 ms 932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6061 ms 2244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6058 ms 2144 KB Time limit exceeded
2 Halted 0 ms 0 KB -