Submission #48399

#TimeUsernameProblemLanguageResultExecution timeMemory
48399ernestvwWeighting stones (IZhO11_stones)C++11
0 / 100
97 ms5244 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; int nbStones; int MINI[300000]; int MAXI[300000]; int lazy[300000]; const int oo = 1e9; void update(int l, int r, int L, int R, int n, int val){ if(lazy[n]){ MINI[n]+=lazy[n]; MAXI[n]+=lazy[n]; lazy[2*n+1]+=lazy[n]; lazy[2*n+2]+=lazy[n]; lazy[n]=0; } if(l>r or R<l or L>r)return; if(L <= l and r <= R){ lazy[2*n+1]+=val; lazy[2*n+2]+=val; MAXI[n]+=val; MINI[n]+=val; return; } update(l, (l+r)/2, L, R, 2*n+1, val); update((l+r)/2+1, r, L, R, 2*n+2, val); MINI[n]=min(MINI[2*n+1], MINI[2*n+2]); MAXI[n]=max(MAXI[2*n+1], MAXI[2*n+2]); } int MIN(){ if(lazy[0]){ lazy[1]+=lazy[0]; lazy[2]+=lazy[0]; MINI[0]+=lazy[0]; MAXI[0]+=lazy[0]; lazy[0]=0; } return MINI[0]; } int MAX(){ if(lazy[0]){ lazy[1]+=lazy[0]; lazy[2]+=lazy[0]; MINI[0]+=lazy[0]; MAXI[0]+=lazy[0]; lazy[0]=0; } return MAXI[0]; } int main(){ scanf("%d", &nbStones); fill_n(MINI, 300000, 0); fill_n(MAXI, 300000, 0); int maxi = 0; int mini = 0; for(int q = 1; q <= nbStones; q++){ int indice, side; scanf("%d%d", &indice, &side); /*for(int i = 1; i <= nbStones; i++) if(i <= indice) suffix[i]+=(side==1?1:-1); maxi=0,mini=0; for(int i=1;i<=nbStones;i++) maxi=max(maxi, suffix[i]), mini=min(mini, suffix[i]);*/ update(0, nbStones, 1, indice, 0, (side==1?1:-1)); maxi=MAX(); mini=MIN(); if(maxi>0 and mini<0)printf("?"); else if(maxi==0 and mini==0)printf("?"); else if(maxi>0)printf(">"); else if(mini<0)printf("<"); printf("\n"); } }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &nbStones);
     ~~~~~^~~~~~~~~~~~~~~~~
stones.cpp:66:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &indice, &side);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...