제출 #1342608

#제출 시각아이디문제언어결과실행 시간메모리
1342608SemicolonSjeckanje (COCI21_sjeckanje)C++20
15 / 110
7 ms4932 KiB
/**
 *     Author: Lưu Diệp Thành (Save Diệp Thành)
 *     Le Hong Phong High School for the Gifted (i2528)
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define ll long long
#define ushort unsigned short
#define FOR(i,l,r) for(int i = (l), _r = (r); i <= _r; i++)
#define FORN(i,r,l) for(int i = (r), _l = (l); i >= _l; i--)
#define endl '\n'
#define sz(x) (int)x.size()
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define MASK(x) (1LL << (x))
#define BIT(x,i) (((x) >> (i)) & 1)
#define ins insert
#define segleft (id<<1)
#define segright (id<<1|1)
#define TIME  (1.0 * clock() / CLOCKS_PER_SEC)
const int MOD = 1e9+7;

struct info {
    int l,r,x;
};

const int N = 2e5+5;
vector<info> query(N);
int a[N];
int n,q;

int checksub() {
    if (n <= 200) {
        return 1;
    } else if (n <= 3000 && q <= 3000) {
        return 2;
    }
    return 3;
}

namespace subtask1 {
    void solve() {
        FOR(t, 1, q) {
            auto[l,r,x] = query[t];
            vector<int> dp(n+5);

            FOR(i, l, r) a[i] += x;

            FOR(i, 1, n) {
                int mx = LLONG_MIN, mn = LLONG_MAX;
                FORN(j, i, 1) {
                    mx = max(mx, a[j]);
                    mn = min(mn, a[j]);
                    dp[i] = max(dp[i], mx - mn + dp[j-1]);
                }
            }
            cout << dp[n] << endl;
        }
    }
}

namespace subtask2 {
    void solve() {

    }
}

namespace subtask3 {
    void solve() {

    }
}

void Semicolon() {
    cin >> n >> q;

    FOR(i, 1, n) cin >> a[i];

    FOR(i, 1, q) {
        cin >> query[i].l >> query[i].r >> query[i].x;
    }

    int c = checksub();
    if (c==1) {
        subtask1::solve();
    } else if (c==2) {
        subtask2::solve();
    } else {
        subtask3::solve();
    }
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
    int t = 1;
    //cin >> t;
    while(t--) Semicolon();

    cerr << endl;
    cerr << "Time elapsed: " << TIME << " s.\n ";
    return (0 ^ 0);
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:100:41: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  100 |     if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
      |                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...