답안 #1114624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114624 2024-11-19T09:24:56 Z cpnoteasy 나머지들의 합 (NOI12_modsum) C++17
25 / 25
1850 ms 7360 KB
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<typename Key, typename Compare = std::less<>>
using ordered_set = __gnu_pbds::tree<Key, __gnu_pbds::null_type, Compare, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
 
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(NULL);
 
    int n, tl = 0;
    pair<int, int> arr[1001];
    multiset<int> sum;
    sum.insert(0);
    
    cin >> n;
    for (int i = 1; i <= n; i++){
        int l, r;
        cin >> l >> r;
        arr[i] = make_pair(l, r);
    }
    
    for (int i = 1; i <= n; i++){
        vector<int> rec(sum.begin(), sum.end());
        for (int k = 0; k < rec.size(); k++){
            sum.erase(sum.find(rec[k]));
            for (int j = arr[i].first; j <= arr[i].second; j++){
                sum.insert((rec[k] + j) % 5);
            }
        }
    }
    
    for (auto it : sum){
        tl += int((pow(it, 4)) + 2 * it * it) % 5 + 1;
    }
    cout << tl << endl;
}





Compilation message

modsum.cpp: In function 'int main()':
modsum.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int k = 0; k < rec.size(); k++){
      |                         ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 12 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 53 ms 2128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 48 ms 1160 KB Output is correct
4 Correct 6 ms 336 KB Output is correct
5 Correct 129 ms 3528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 140 ms 840 KB Output is correct
2 Correct 8 ms 336 KB Output is correct
3 Correct 574 ms 7360 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
5 Correct 1850 ms 3836 KB Output is correct