답안 #545061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545061 2022-04-03T13:24:50 Z Asymmetry Fire (JOI20_ho_t5) C++17
1 / 100
1000 ms 11752 KB
//Autor: Bartłomiej Czarkowski
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif

struct pytanie {
	int l, r, id;
};

const int N = 201000;
int n, q;
int t[N];
long long odp[N];
vector<pytanie> pyt[N]; // zapytania po czasie

int main() {
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &t[i]);
	}
	for (int i = 1; i <= q; ++i) {
		int a, b, c;
		scanf("%d%d%d", &c, &a, &b);
		pyt[c].push_back({a, b, i});
	}
	
	for (int i = 1; i <= n; ++i) {
		for (int j = n; j; --j) {
			t[j] = max(t[j], t[j - 1]);
		}
		
		for (auto j : pyt[i]) {
			long long ret = 0;
			for (int k = j.l; k <= j.r; ++k) {
				ret += t[k];
			}
			odp[j.id] = ret;
		}
	}
	
	for (int i = 1; i <= q; ++i) {
		printf("%lld\n", odp[i]);
	}
	return 0;
}

Compilation message

ho_t5.cpp: In function 'int main()':
ho_t5.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  scanf("%d%d", &n, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~
ho_t5.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   scanf("%d", &t[i]);
      |   ~~~~~^~~~~~~~~~~~~
ho_t5.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d%d%d", &c, &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 5032 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 5028 KB Output is correct
10 Correct 3 ms 5032 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5032 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5032 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 5036 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 5032 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 3 ms 5036 KB Output is correct
23 Correct 4 ms 5040 KB Output is correct
24 Correct 3 ms 4948 KB Output is correct
25 Correct 3 ms 5032 KB Output is correct
26 Correct 4 ms 5040 KB Output is correct
27 Correct 3 ms 4948 KB Output is correct
28 Correct 3 ms 4948 KB Output is correct
29 Correct 3 ms 5040 KB Output is correct
30 Correct 4 ms 5040 KB Output is correct
31 Correct 4 ms 4948 KB Output is correct
32 Correct 3 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 1093 ms 8892 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 1078 ms 11752 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 11736 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 5032 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 5028 KB Output is correct
10 Correct 3 ms 5032 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5032 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5032 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 5036 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 5032 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 3 ms 5036 KB Output is correct
23 Correct 4 ms 5040 KB Output is correct
24 Correct 3 ms 4948 KB Output is correct
25 Correct 3 ms 5032 KB Output is correct
26 Correct 4 ms 5040 KB Output is correct
27 Correct 3 ms 4948 KB Output is correct
28 Correct 3 ms 4948 KB Output is correct
29 Correct 3 ms 5040 KB Output is correct
30 Correct 4 ms 5040 KB Output is correct
31 Correct 4 ms 4948 KB Output is correct
32 Correct 3 ms 4948 KB Output is correct
33 Execution timed out 1093 ms 8892 KB Time limit exceeded
34 Halted 0 ms 0 KB -