|
|
вернуться в форум772kb and still got MLE#10, please help me #include <iostream> using namespace std; struct duy{ long long x; int y; }; int n,x,last[1001]; long long y; duy m[100001]; char s[5]; int main() { cin.tie(NULL); cout.tie(NULL); cin>>n; for(int i=1; i<=n; i++){ cin>>s>>x; if(s[1]=='U'){ cin>>y; m[i].x=y; m[i].y=last[x]; last[x]=i; } else{ cout<<m[last[x]].x; last[x]=m[last[x]].y; } } } Re: 772kb and still got MLE#10, please help me By task description, B is an integer (0 ≤ B ≤ 10^9). So "int x", not "long long x". But it shouldn't be enough. Please estimate (or just type from local run) sizeof(duy) and sizeof(m). Then read task memory restriction. Assume that even "empty main()" program spends about 100 Kb (see successful runs of "1000 A+B" problem for your compiler). In this case duy can hold not only one x, but bucket - ~30 values for example. More, 30 bits are required to save B. So it's possible to save 32 values into "int x[30]" array. Edited by author 10.03.2017 15:50 |
|
|