답안 #383141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
383141 2021-03-28T22:04:28 Z Iwanttobreakfree Unija (COCI17_unija) C++17
100 / 100
821 ms 35328 KB
#include <iostream>
#include <vector>
using namespace std;
int main(){
	long long int n,a,b,maxa=0,maxb=0,area=0;
	cin>>n;
	vector<int> v(5000000,0);
	while(n--){
		cin>>a>>b;
		if(v[a]<b)v[a]=b;
		if(a>maxa)maxa=a;
	}
	int maxi=0;
	for(int i=maxa;i>=1;i--){
		if(v[i]>maxi)maxi=v[i];
		area+=maxi;
	}
	cout<<area;
}

Compilation message

unija.cpp: In function 'int main()':
unija.cpp:5:29: warning: unused variable 'maxb' [-Wunused-variable]
    5 |  long long int n,a,b,maxa=0,maxb=0,area=0;
      |                             ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19820 KB Output is correct
2 Correct 13 ms 19820 KB Output is correct
3 Correct 13 ms 19840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 19820 KB Output is correct
2 Correct 14 ms 19948 KB Output is correct
3 Correct 14 ms 19948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 19948 KB Output is correct
2 Correct 14 ms 19948 KB Output is correct
3 Correct 14 ms 19948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 19948 KB Output is correct
2 Correct 16 ms 19948 KB Output is correct
3 Correct 17 ms 19948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 812 ms 35168 KB Output is correct
2 Correct 821 ms 34924 KB Output is correct
3 Correct 796 ms 35052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 19820 KB Output is correct
2 Correct 14 ms 19820 KB Output is correct
3 Correct 14 ms 19820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 20204 KB Output is correct
2 Correct 32 ms 20204 KB Output is correct
3 Correct 32 ms 20204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 21228 KB Output is correct
2 Correct 79 ms 21228 KB Output is correct
3 Correct 84 ms 21356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 226 ms 23928 KB Output is correct
2 Correct 232 ms 23916 KB Output is correct
3 Correct 224 ms 23916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 807 ms 35040 KB Output is correct
2 Correct 802 ms 35328 KB Output is correct
3 Correct 803 ms 35040 KB Output is correct