Submission #50335

# Submission time Handle Problem Language Result Execution time Memory
50335 2018-06-10T08:33:39 Z gnoor Sterilizing Spray (JOI15_sterilizing) C++17
80 / 100
5000 ms 5796 KB
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

map<int,int> st;

int main () {
	int n,q,k;
	scanf("%d%d%d",&n,&q,&k);
	int x;
	for (int i=1;i<=n;i++) {
		scanf("%d",&x);
		//st.insert(make_pair(i,x));
		st[i]=x;
	}
	int a,b,c;
	for (int i=0;i<q;i++) {
		scanf("%d%d%d",&a,&b,&c);
		if (a==1) {
			//auto &now = st.lower_bound(make_pair(b,-1));
			st[b]=c;
		} else if (a==2) {
			if (k==1) continue;
			auto xx=st.lower_bound(b);
			for(;xx->first<=c&&xx!=st.end();) {
				xx->second/=k;
				if (xx->second==0) {
					auto tmp=xx;
					xx++;
					st.erase(tmp);
				} else {
					xx++;
				}
			}
		} else if (a==3) {
			auto xx=st.lower_bound(b);
			long long ans=0;
			for (;xx->first<=c&&xx!=st.end();xx++) {
				ans+=xx->second;
			}
			printf("%lld\n",ans);
		}
	}
	return 0;
}

Compilation message

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&q,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~
sterilizing.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
sterilizing.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&a,&b,&c);
   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 444 KB Output is correct
4 Correct 7 ms 444 KB Output is correct
5 Correct 7 ms 520 KB Output is correct
6 Correct 6 ms 520 KB Output is correct
7 Correct 7 ms 520 KB Output is correct
8 Correct 5 ms 620 KB Output is correct
9 Correct 9 ms 620 KB Output is correct
10 Correct 6 ms 620 KB Output is correct
11 Correct 7 ms 724 KB Output is correct
12 Correct 6 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4517 ms 3464 KB Output is correct
2 Correct 2618 ms 3464 KB Output is correct
3 Correct 4735 ms 4752 KB Output is correct
4 Execution timed out 5100 ms 5788 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 5788 KB Output is correct
2 Correct 43 ms 5788 KB Output is correct
3 Correct 35 ms 5788 KB Output is correct
4 Correct 58 ms 5788 KB Output is correct
5 Correct 88 ms 5788 KB Output is correct
6 Correct 89 ms 5788 KB Output is correct
7 Execution timed out 5014 ms 5788 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 76 ms 5788 KB Output is correct
2 Correct 90 ms 5788 KB Output is correct
3 Correct 90 ms 5788 KB Output is correct
4 Correct 82 ms 5788 KB Output is correct
5 Correct 139 ms 5788 KB Output is correct
6 Correct 143 ms 5788 KB Output is correct
7 Correct 140 ms 5788 KB Output is correct
8 Correct 157 ms 5788 KB Output is correct
9 Correct 156 ms 5788 KB Output is correct
10 Correct 158 ms 5788 KB Output is correct
11 Correct 126 ms 5788 KB Output is correct
12 Correct 216 ms 5796 KB Output is correct