Submission #946951

# Submission time Handle Problem Language Result Execution time Memory
946951 2024-03-15T08:15:38 Z mariamp1 Foehn Phenomena (JOI17_foehn_phenomena) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define int long long;
 
const int maxn = 2e5+10;
 
int n, q, a[maxn];
int sum, dif[maxn], s, t;
 
int32_t main()
{
	cin >> n >> q >> s >> t;
 
	for(int i = 0 ; i <= n ; i++) cin >> a[i];	
 
	for(int i = 1 ; i <= n ; i++)
	{
		dif[i] = a[i]-a[i-1];
		if(dif[i] <= 0) sum += abs(dif[i]*t);
		else sum -= abs(dif[i]*s);
	}
 
	//cout << sum << endl;
 
	dif[0] = dif[n+1] = 0;
 
	//for(int i = 1 ; i <= n ; i++) cout << dif[i] << ' ';
	//cout << endl;
 
	for(int i = 0 ; i < q ; i++)
	{
		int l, r, x;
		cin >> l >> r >> x;
 
		//cout << dif[l] << ' ' << dif[r+1] << endl; 
 
		if(dif[l] <= 0) sum -= abs(dif[l]*t);
		else sum += abs(dif[l]*s);
 
		if(dif[r+1] <= 0) sum -= abs(dif[r+1]*t);
		else sum += abs(dif[r+1]*s);
 
		dif[l] += x;
		if(r+1 <= n) dif[r+1] -= x;
 
		if(dif[l] <= 0) sum += abs(dif[l]*t);
		else sum -= abs(dif[l]*s);
 
		if(dif[r+1] <= 0) sum += abs(dif[r+1]*t);
		else sum -= abs(dif[r+1]*s);		
	
		//cout << dif[l] << ' ' << dif[r+1] << endl; 
 
		cout << sum << endl;
	
	//	for(int i = 1 ; i <= n ; i++) cout << dif[i] << ' ';
	}
}

Compilation message

foehn_phenomena.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
foehn_phenomena.cpp:8:7: note: in expansion of macro 'int'
    8 | const int maxn = 2e5+10;
      |       ^~~
foehn_phenomena.cpp:8:11: error: 'maxn' does not name a type
    8 | const int maxn = 2e5+10;
      |           ^~~~
foehn_phenomena.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
foehn_phenomena.cpp:10:1: note: in expansion of macro 'int'
   10 | int n, q, a[maxn];
      | ^~~
foehn_phenomena.cpp:10:5: error: 'n' does not name a type
   10 | int n, q, a[maxn];
      |     ^
foehn_phenomena.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
foehn_phenomena.cpp:11:1: note: in expansion of macro 'int'
   11 | int sum, dif[maxn], s, t;
      | ^~~
foehn_phenomena.cpp:11:5: error: 'sum' does not name a type
   11 | int sum, dif[maxn], s, t;
      |     ^~~
foehn_phenomena.cpp: In function 'int32_t main()':
foehn_phenomena.cpp:15:9: error: 'n' was not declared in this scope
   15 |  cin >> n >> q >> s >> t;
      |         ^
foehn_phenomena.cpp:15:14: error: 'q' was not declared in this scope
   15 |  cin >> n >> q >> s >> t;
      |              ^
foehn_phenomena.cpp:15:19: error: 's' was not declared in this scope
   15 |  cin >> n >> q >> s >> t;
      |                   ^
foehn_phenomena.cpp:15:24: error: 't' was not declared in this scope; did you mean 'tm'?
   15 |  cin >> n >> q >> s >> t;
      |                        ^
      |                        tm
foehn_phenomena.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
foehn_phenomena.cpp:17:6: note: in expansion of macro 'int'
   17 |  for(int i = 0 ; i <= n ; i++) cin >> a[i];
      |      ^~~
foehn_phenomena.cpp:17:10: error: 'i' was not declared in this scope
   17 |  for(int i = 0 ; i <= n ; i++) cin >> a[i];
      |          ^
foehn_phenomena.cpp:17:24: error: expected ')' before ';' token
   17 |  for(int i = 0 ; i <= n ; i++) cin >> a[i];
      |     ~                  ^~
      |                        )
foehn_phenomena.cpp:17:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   17 |  for(int i = 0 ; i <= n ; i++) cin >> a[i];
      |  ^~~
foehn_phenomena.cpp:17:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   17 |  for(int i = 0 ; i <= n ; i++) cin >> a[i];
      |                           ^
foehn_phenomena.cpp:17:27: error: 'i' was not declared in this scope
foehn_phenomena.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
foehn_phenomena.cpp:19:6: note: in expansion of macro 'int'
   19 |  for(int i = 1 ; i <= n ; i++)
      |      ^~~
foehn_phenomena.cpp:19:24: error: expected ')' before ';' token
   19 |  for(int i = 1 ; i <= n ; i++)
      |     ~                  ^~
      |                        )
foehn_phenomena.cpp:19:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   19 |  for(int i = 1 ; i <= n ; i++)
      |  ^~~
foehn_phenomena.cpp:19:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   19 |  for(int i = 1 ; i <= n ; i++)
      |                           ^
foehn_phenomena.cpp:28:2: error: 'dif' was not declared in this scope; did you mean 'div'?
   28 |  dif[0] = dif[n+1] = 0;
      |  ^~~
      |  div
foehn_phenomena.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
foehn_phenomena.cpp:33:6: note: in expansion of macro 'int'
   33 |  for(int i = 0 ; i < q ; i++)
      |      ^~~
foehn_phenomena.cpp:33:23: error: expected ')' before ';' token
   33 |  for(int i = 0 ; i < q ; i++)
      |     ~                 ^~
      |                       )
foehn_phenomena.cpp:33:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   33 |  for(int i = 0 ; i < q ; i++)
      |  ^~~
foehn_phenomena.cpp:33:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   33 |  for(int i = 0 ; i < q ; i++)
      |                          ^