답안 #869121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869121 2023-11-03T09:03:49 Z Alora Sjeckanje (COCI21_sjeckanje) C++17
0 / 110
1 ms 2396 KB
#include <bits/stdc++.h>
#define Alora "cownav"
#define fi(i,a,b) for(int i = a; i <= b; i++)
#define fid(i,a,b) for(int i = a; i >= b; i--)
#define ll long long
#define f first
#define se second
#define pii pair<int, int>
#define getbit(i, j) ((i >> j) & 1)
#define all(v) v.begin(), v.end()
#define pb push_back
#define maxn 200005
const int M = 1e9 + 7;
using namespace std;
int m, n;
ll a[maxn], dp[3][maxn];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	if(fopen(Alora".inp","r")){
    freopen(Alora".inp","r",stdin);
    freopen(Alora".out","w",stdout);}
    cin >> n >> m;
    fi(i, 1, n) cin >> a[i];
    while(m--){
        int l, r, x;
        cin >> l >> r >> x;
        fi(i, l, r) a[i] += x;
        dp[0][1] = dp[1][1] = 0;
        fi(i, 2, n){
            dp[0][i] = max(dp[0][i - 1], dp[1][i - 1]);
            dp[1][i] = dp[0][i - 1] + abs(a[i] - a[i - 1]);
        }
        cout << max(dp[0][n], dp[1][n]) << '\n';
    }
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen(Alora".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen(Alora".out","w",stdout);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -