Submission #548490

#TimeUsernameProblemLanguageResultExecution timeMemory
548490Um_nikFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
135 ms11500 KiB
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <bitset> using namespace std; #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr); #else #define eprintf(...) 42 #endif using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; template<typename T> using pair2 = pair<T, T>; using pii = pair<int, int>; using pli = pair<ll, int>; using pll = pair<ll, ll>; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second clock_t startTime; double getCurrentTime() { return (double)(clock() - startTime) / CLOCKS_PER_SEC; } const int N = (int)1e6 + 5; int n, q; ll s, t; ll a[N]; ll ans; ll getVal(ll x) { if (x >= 0) return -x * s; return -x * t; } int main() { startTime = clock(); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d%d%lld%lld", &n, &q, &s, &t); ll lst = 0; scanf("%lld", &lst); for (int i = 0; i < n; i++) { ll x; scanf("%lld", &x); a[i] = x - lst; ans += getVal(a[i]); lst = x; } while(q--) { int l, r; ll x; scanf("%d%d%lld", &l, &r, &x); l--; ans -= getVal(a[l]); a[l] += x; ans += getVal(a[l]); if (r < n) { ans -= getVal(a[r]); a[r] -= x; ans += getVal(a[r]); } printf("%lld\n", ans); } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:70:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |  scanf("%d%d%lld%lld", &n, &q, &s, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:72:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |  scanf("%lld", &lst);
      |  ~~~~~^~~~~~~~~~~~~~
foehn_phenomena.cpp:75:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |   scanf("%lld", &x);
      |   ~~~~~^~~~~~~~~~~~
foehn_phenomena.cpp:83:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |   scanf("%d%d%lld", &l, &r, &x);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...