Submission #379315

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3793152021-03-18 01:19:44ChrisTSalesman (IOI09_salesman)C++17
100 / 100
1405 ms46468 KiB
#include<bits/stdc++.h>
using namespace std;
const int MN = 5e5 + 5;
struct Seg {
int tree[MN << 1]; int n;
Seg() {n = MN; memset(tree,-0x3f,sizeof tree);}
void update (int i, int v) {
for (tree[i += n-1] = v; i > 1; i >>= 1)
tree[i>>1] = max(tree[i],tree[i^1]);
}
int query (int l, int r) {
int ret = -1e9;
for (l += n-1, r += n; l < r; l >>= 1, r >>= 1) {
if (l&1) ret = max(ret,tree[l++]);
if (r&1) ret = max(ret,tree[--r]);
}
return ret;
}
} segL, segR, segL2, segR2;
vector<array<int,2>> atT[MN];
int main () {
int n,u,d,s;
scanf ("%d %d %d %d",&n,&u,&d,&s);
while (n--) {
int t,l,m; scanf ("%d %d %d",&t,&l,&m);
atT[t].push_back({l,m});
}
atT[MN-1].push_back({s,0});
segL.update(s,d * s); segR.update(s,-u*s);
for (int t = 1; t < MN; t++) if (!atT[t].empty()) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

salesman.cpp: In function 'int main()':
salesman.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |  scanf ("%d %d %d %d",&n,&u,&d,&s);
      |  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
salesman.cpp:25:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   int t,l,m; scanf ("%d %d %d",&t,&l,&m);
      |              ~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...